pngjs-image
Advanced tools
Comparing version 0.11.0 to 0.11.1
CHANGELOG | ||
========= | ||
v0.11.1 - 04/20/15 | ||
* Add rotateCW/rotateCCW methods | ||
* Add experimental feature | ||
* Add synchronous PNG loader (readImageSync) | ||
v0.11.0 - 04/19/15 | ||
@@ -5,0 +10,0 @@ * Add experimental features: |
17
index.js
@@ -8,2 +8,3 @@ // Copyright 2014-2015, Yahoo! Inc. | ||
pixel = require('./lib/pixel'), | ||
modify = require('./lib/modify'), | ||
conversion = require('./lib/conversion'), | ||
@@ -82,2 +83,3 @@ filters = require('./lib/filters'), | ||
/** | ||
@@ -97,2 +99,3 @@ * Copies an already existing image | ||
/** | ||
@@ -127,2 +130,15 @@ * Reads an image from the filesystem | ||
/** | ||
* Reads an image from the filesystem synchronously | ||
* | ||
* @static | ||
* @method readImageSync | ||
* @param {string} filename | ||
* @return {PNGImage} | ||
*/ | ||
PNGImage.readImageSync = function (filename) { | ||
return this.loadImageSync(fs.readFileSync(filename)); | ||
}; | ||
/** | ||
* Loads an image from a blob | ||
@@ -422,2 +438,3 @@ * | ||
_.extend(PNGImage.prototype, pixel); | ||
_.extend(PNGImage.prototype, modify); | ||
_.extend(PNGImage.prototype, conversion); | ||
@@ -424,0 +441,0 @@ |
@@ -55,3 +55,3 @@ // Copyright 2014-2015 Yahoo! Inc. | ||
* @param {int} idx Index of pixel | ||
* @param {object} color | ||
* @param {object|int} color | ||
* @param {int} [color.red] Red value for pixel | ||
@@ -64,6 +64,13 @@ * @param {int} [color.green] Green value for pixel | ||
setAtIndex: function (idx, color) { | ||
if (color.red !== undefined) this.setRed(idx, color.red, color.opacity); | ||
if (color.green !== undefined) this.setGreen(idx, color.green, color.opacity); | ||
if (color.blue !== undefined) this.setBlue(idx, color.blue, color.opacity); | ||
if (color.alpha !== undefined) this.setAlpha(idx, color.alpha, color.opacity); | ||
if (typeof color === 'object') { | ||
if (color.red !== undefined) this.setRed(idx, color.red, color.opacity); | ||
if (color.green !== undefined) this.setGreen(idx, color.green, color.opacity); | ||
if (color.blue !== undefined) this.setBlue(idx, color.blue, color.opacity); | ||
if (color.alpha !== undefined) this.setAlpha(idx, color.alpha, color.opacity); | ||
} else { | ||
this.setRed(idx, color & 0xff); | ||
this.setGreen(idx, (color & 0xff00) >> 8); | ||
this.setBlue(idx, (color & 0xff0000) >> 16); | ||
this.setAlpha(idx, (color & 0xff000000) >> 24); | ||
} | ||
}, | ||
@@ -70,0 +77,0 @@ |
{ | ||
"name": "pngjs-image", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Native PNG image manipulation", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
89692
48
2660