Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

jimp

Package Overview
Dependencies
Maintainers
1
Versions
281
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jimp - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

56

jimp.js
var FS = require("fs");
var PNG = require("pngjs").PNG;
var JPEG = require("jpeg-js");
var Bitmap = require("node-bitmap");
var MIME = require("mime");

@@ -9,2 +10,3 @@ var Resize = require("./resize.js");

var MIME_JPEG = "image/jpeg";
var MIME_BMP = "image/bmp";

@@ -61,2 +63,15 @@

break;
// case MIME_BMP:
// FS.readFile(path, function (err, data) {
// if (err) throw err;
// var bmp = new Bitmap(data);
// bmp.init();
// _this.bitmap = {
// data: bmp.getData(false),
// width: bmp.getWidth(),
// height: bmp.getHeight()
// }
// cb.call(_this);
// });
// break;
default:

@@ -138,8 +153,6 @@ throw new Error("Unsupported MIME type: " + mime);

this.scan(x, y, w, h, function (x, y, idx) {
bitmap = bitmap.concat([
this.bitmap.data[idx],
this.bitmap.data[idx+1],
this.bitmap.data[idx+2],
this.bitmap.data[idx+3]
]);
bitmap.push(this.bitmap.data[idx]);
bitmap.push(this.bitmap.data[idx+1]);
bitmap.push(this.bitmap.data[idx+2]);
bitmap.push(this.bitmap.data[idx+3]);
});

@@ -169,2 +182,25 @@

/**
* Flip the image horizontally
* @param horizontal a Boolean, if true the image will be flipped horizontally
* @param vertical a Boolean, if true the image will be flipped vertically
* @returns this for chaining of methods
*/
Jimp.prototype.flip = function (horizontal, vertical) {
var bitmap = [];
this.scan(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
var _x = (horizontal) ? (this.bitmap.width - x) : x;
var _y = (vertical) ? (this.bitmap.height - y) : y;
var _idx = (this.bitmap.width * _y + _x) << 2;
bitmap.push(this.bitmap.data[_idx]);
bitmap.push(this.bitmap.data[_idx+1]);
bitmap.push(this.bitmap.data[_idx+2]);
bitmap.push(this.bitmap.data[_idx+3]);
});
this.bitmap.data = new Buffer(bitmap);
return this;
};
/**
* Applies a true Gaussian blur to the image (warning: this is VERY slow)

@@ -431,2 +467,4 @@ * @param r the pixel radius of the blur

throw new Error("w and h must be numbers");
w = Math.round(w);
h = Math.round(h);
var _this = this;

@@ -473,3 +511,2 @@ var resize = new Resize(this.bitmap.width, this.bitmap.height, w, h, true, true, function (buffer) {

var _this = this;
var mime = MIME.lookup(path);

@@ -479,2 +516,3 @@

case MIME_PNG:
var _this = this;
var png = new PNG();

@@ -490,7 +528,7 @@ png.data = new Buffer(this.bitmap.data);

case MIME_JPEG:
var jpeg = JPEG.encode(_this.bitmap, _this._quality);
var jpeg = JPEG.encode(this.bitmap, this._quality);
var stream = FS.createWriteStream(path);
stream.write(jpeg.data);
stream.end();
cb.call(_this);
cb.call(this);
break;

@@ -497,0 +535,0 @@ default:

11

package.json
{
"name": "jimp",
"version": "0.1.1",
"version": "0.1.2",
"description": "An image processing library written entirely in JavaScript (i.e. zero external or native dependencies).",

@@ -25,11 +25,12 @@ "main": "jimp.js",

"jpeg-js": "0.0.4",
"mime": "~1.2.11"
"mime": "~1.2.11",
"node-bitmap": "0.0.1"
},
"repository": {
"type" : "git",
"url" : "https://github.com/oliver-moran/jimp.git"
"type": "git",
"url": "https://github.com/oliver-moran/jimp.git"
},
"bugs": {
"url" : "https://github.com/oliver-moran/jimp/issues"
"url": "https://github.com/oliver-moran/jimp/issues"
}
}

@@ -35,2 +35,5 @@ # Jimp #

image.invert(); // invert the image colours
image.flip( horz, vert); // flip the image horizontally or vertically
image.gaussian( r ); // Gaussian blur the image by r pixels (VERY slow)
image.blur( r ); // fast blur the image by r pixels
image.greyscale(); // remove colour from the image

@@ -41,4 +44,2 @@ image.sepia(); // apply a sepia wash to the image

image.scale( f ); // scale the image by the factor f
image.blur( r ); // fast blur the image by r pixels
image.gaussian( r ); // Gaussian blur the image by r pixels (VERY slow)

@@ -45,0 +46,0 @@ (Contributions of more methods are welcome!)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc