resizeExact function

master
Dan Rocha 9 years ago
parent dd814261e8
commit b1fbac5ba4
  1. 9
      lib/args.js
  2. 16
      test/resizeWrong.js

@ -57,7 +57,7 @@ module.exports = function (proto) {
* img.append(img).append(true) gm convert src img +append
* img.append(img).append(true) gm convert src img +append
* img.append(img).background('#222) gm convert src img -background #222 +append
* img.append([img1,img2...],true)
* img.append([img1,img2...],true)
* @param {String} or {Array} [img]
* @param {Boolean} [ltr]
@ -710,7 +710,7 @@ module.exports = function (proto) {
var geometry,
wIsValid = Boolean(w || w === 0),
hIsValid = Boolean(h || h === 0);
if (wIsValid && hIsValid) {
geometry = w + "x" + h + options
} else if (wIsValid) {
@ -726,6 +726,11 @@ module.exports = function (proto) {
return this.out("-resize", geometry);
}
proto.resizeExact = function resize (w, h) {
var options = "!";
return proto.resize.apply(this, [w, h, options]);
}
// http://www.graphicsmagick.org/GraphicsMagick.html#details-scale
proto.scale = function scale (w, h, options) {
options = options || "";

@ -24,7 +24,21 @@ module.exports = function (_, dir, finish, gm) {
gm(name)
.size(function (err, size) {
if (err) return finish(err);
if (size.width !== width) return finish("Wrong resizing on requested:" + width + ", resized:" + size.width);
if (size.width !== width) {
gm(original)
.resizeExact(width)
.write(name, function (err) {
if (err) return finish(err);
gm(name)
.size(function (err, size) {
if (err) return finish(err);
if (size.width !== width) {
return finish("Wrong resizing on requested:" + width + ", resized:" + size.width);
}
});
});
}
if (cb) return cb();
resize(widths[index], index);

Loading…
Cancel
Save