gulp-image-resize
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -133,2 +133,6 @@ var gulp = require("gulp"); | ||
resize("test/fixtures/hamburg.jpg", "noProfile", { | ||
noProfile: true | ||
}); | ||
gulp.task("image_resize", resizeTasks); | ||
@@ -135,0 +139,0 @@ |
14
index.js
@@ -21,2 +21,3 @@ /* | ||
quality : 1, | ||
noProfile : false, | ||
sharpen : false, | ||
@@ -45,9 +46,9 @@ imageMagick : false, | ||
// if upscale is not requested, restrict size | ||
// if upscale is not requested, restrict size | ||
if(!options.upscale){ | ||
// Math.min(undefined, 5) will return NaN, so it can stay undefined | ||
options.width = Math.min(options.width, size.width); | ||
options.width = Math.min(options.width, size.width); | ||
options.height = Math.min(options.height, size.height); | ||
} | ||
// if one dimension is not set - we fill it proportionally | ||
@@ -62,3 +63,3 @@ if (!options.height) { | ||
if (!options.width) { | ||
if (options.crop) { | ||
if (options.crop) { | ||
options.width = size.width; | ||
@@ -106,2 +107,6 @@ } else { | ||
if (options.noProfile) { | ||
gmfile = gmfile.noProfile(); | ||
} | ||
callback(null, gmfile); | ||
@@ -115,2 +120,1 @@ } | ||
}; | ||
{ | ||
"name": "gulp-image-resize", | ||
"description": "Resizing images made easy.", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"homepage": "https://github.com/scalableminds/gulp-image-resize", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -32,3 +32,3 @@ # [gulp](https://github.com/wearefractal/gulp)-image-resize [![Build Status](https://drone.io/github.com/scalableminds/gulp-image-resize/status.png)](https://drone.io/github.com/scalableminds/gulp-image-resize/latest) | ||
Windows & others: | ||
Windows & others: | ||
@@ -48,3 +48,3 @@ [http://www.imagemagick.org/script/binary-releases.php](http://www.imagemagick.org/script/binary-releases.php) | ||
gulp.src('test.png') | ||
.pipe(imageResize({ | ||
.pipe(imageResize({ | ||
width : 100, | ||
@@ -142,2 +142,12 @@ height : 100, | ||
#### options.noProfile | ||
Type: `Boolean` | ||
Default value: `false` | ||
Set to `true` to enforce removal of all embedded profile data like icc, exif, iptc, xmp | ||
and so on. If source files represent e.g. untouched camera data or images optimized for | ||
print this may decrease image size drastically. Therefore this is probably wanted in | ||
cases where thumbnails are generated for web preview purposes. For details look for parameter _+profile "*"_ in the [gm profile documentation](http://www.graphicsmagick.org/GraphicsMagick.html#details-profile). | ||
#### options.imageMagick | ||
@@ -171,3 +181,3 @@ | ||
gulp.src('test.png') | ||
.pipe(imageResize({ | ||
.pipe(imageResize({ | ||
width : 100 | ||
@@ -231,2 +241,1 @@ })) | ||
MIT © [scalable minds](http://scm.io) | ||
/*global describe, it, before, beforeEach, after, afterEach */ | ||
var gm = require("gm"); | ||
var gm_im = require("gm").subClass({imageMagick: true}); | ||
var async = require("async"); | ||
@@ -99,3 +100,3 @@ var fs = require("fs"); | ||
it("should crop with gravity", createTests("crop_gravity", "wikipedia.png")); | ||
it("should crop with only width set", createTests("crop_width_only", "wikipedia.png")); | ||
it("should crop with only width set", createTests("crop_width_only", "wikipedia.png")); | ||
}); | ||
@@ -154,1 +155,23 @@ | ||
}); | ||
describe("noProfile", function () { | ||
var filename = "hamburg.jpg"; | ||
it("should remove all profiles (8bim, exif, iptc, xmp...) from the Hamburg image", function (callback) { | ||
async.map([ | ||
path.join(process.cwd(), TMP_FOLDER, "noProfile", filename), | ||
path.join(process.cwd(), TMP_FOLDER, "noProfile_imagemagick", filename) | ||
], function (path, callback) { | ||
gm_im(path).identify("%[profiles]", callback); | ||
}, function (err, results) { | ||
if (err) { | ||
throw err; | ||
} else { | ||
results.forEach(function (format) { | ||
// test passes if result contains no or empty string elements | ||
assert.equal("", format, filename + " contains profiles '" + format + "''" ); | ||
}); | ||
callback(); | ||
} | ||
}); | ||
}); | ||
}); |
1852710
29
349
237