Comparing version 0.2.14 to 0.2.15
67
index.js
@@ -12,2 +12,3 @@ var FS = require("fs"); | ||
var PixelMatch = require("pixelmatch"); | ||
var EXIFParser = require("exif-parser"); | ||
@@ -227,2 +228,3 @@ // polyfill Promise for Node < 0.12 | ||
this.bitmap = JPEG.decode(data); | ||
exifRotate(this, data); // EXIF data | ||
return cb.call(this, null, this); | ||
@@ -239,2 +241,39 @@ | ||
/* | ||
* Automagically rotates a JPEG image based on its EXIF data | ||
* @params image a Jimp image | ||
* @params buffer a buffer array of the raw JPEG data | ||
* @returns nothing | ||
*/ | ||
function exifRotate(image, buffer) { | ||
var exif = EXIFParser.create(buffer).parse(); | ||
if (!exif || !exif.tags || !exif.tags.Orientation) return; | ||
switch (exif.tags.Orientation) { | ||
case 1: // Horizontal (normal) | ||
// do nothing | ||
break; | ||
case 2: // Mirror horizontal | ||
image.mirror(true, false); | ||
break; | ||
case 3: // Rotate 180 | ||
image.rotate(180); | ||
break; | ||
case 4: // Mirror vertical | ||
image.mirror(false, true); | ||
break; | ||
case 5: // Mirror horizontal and rotate 270 CW | ||
image.mirror(true, false).rotate(270); | ||
break; | ||
case 6: // Rotate 90 CW | ||
image.rotate(90); | ||
break; | ||
case 7: // Mirror horizontal and rotate 90 CW | ||
image.mirror(true, false).rotate(90); | ||
break; | ||
case 8: // Rotate 270 CW | ||
image.rotate(270); | ||
break; | ||
} | ||
} | ||
// used to auto resizing etc. | ||
@@ -1503,21 +1542,21 @@ Jimp.AUTO = -1; | ||
actions.forEach(function (action) { | ||
if (action.apply === 'mix') { | ||
if (action.apply === "mix") { | ||
clr = tinycolor.mix(clr, action.params[0], action.params[1]); | ||
} else if (action.apply === 'tint') { | ||
clr = tinycolor.mix(clr, 'white', action.params[0]); | ||
} else if (action.apply === 'shade') { | ||
clr = tinycolor.mix(clr, 'black', action.params[0]); | ||
} else if (action.apply === 'xor') { | ||
} else if (action.apply === "tint") { | ||
clr = tinycolor.mix(clr, "white", action.params[0]); | ||
} else if (action.apply === "shade") { | ||
clr = tinycolor.mix(clr, "black", action.params[0]); | ||
} else if (action.apply === "xor") { | ||
var clr2 = tinycolor(action.params[0]).toRgb(); | ||
clr = clr.toRgb(); | ||
clr = tinycolor({ r: clr.r ^ clr2.r, g: clr.g ^ clr2.g, b: clr.b ^ clr2.b}); | ||
} else if (action.apply === 'red') { | ||
clr = colorModifier('r', action.params[0]); | ||
} else if (action.apply === 'green') { | ||
clr = colorModifier('g', action.params[0]); | ||
} else if (action.apply === 'blue') { | ||
clr = colorModifier('b', action.params[0]); | ||
} else if (action.apply === "red") { | ||
clr = colorModifier("r", action.params[0]); | ||
} else if (action.apply === "green") { | ||
clr = colorModifier("g", action.params[0]); | ||
} else if (action.apply === "blue") { | ||
clr = colorModifier("b", action.params[0]); | ||
} else { | ||
if (action.apply === 'hue') { | ||
action.apply = 'spin'; | ||
if (action.apply === "hue") { | ||
action.apply = "spin"; | ||
} | ||
@@ -1524,0 +1563,0 @@ |
{ | ||
"name": "jimp", | ||
"version": "0.2.14", | ||
"version": "0.2.15", | ||
"description": "An image processing library written entirely in JavaScript (i.e. zero external or native dependencies).", | ||
@@ -30,2 +30,3 @@ "main": "index.js", | ||
"es6-promise": "^3.0.2", | ||
"exif-parser": "^0.1.9", | ||
"file-type": "^3.1.0", | ||
@@ -32,0 +33,0 @@ "jpeg-js": "^0.1.1", |
@@ -61,2 +61,4 @@ # Jimp # | ||
JPEG images with EXIF orientation data will be automatically re-orientated as appropriate. | ||
Once the callback is filed or the promise fulfilled, the following methods can be called on the image: | ||
@@ -63,0 +65,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97417
1943
287
12
+ Addedexif-parser@^0.1.9
+ Addedexif-parser@0.1.12(transitive)