Add support for ImageMagick specfic crop options

Support ImageMagick crop function specific options ! and @.
master
Thomas Eschemann 9 years ago
parent d113cc2d57
commit ec68326027
  1. 7
      lib/args.js
  2. 7
      test/crop.js

@ -789,7 +789,7 @@ module.exports = function (proto) {
}
// http://www.graphicsmagick.org/GraphicsMagick.html#details-crop
proto.crop = function crop (w, h, x, y, percent) {
proto.crop = function crop (w, h, x, y, arg) {
if (this.inputIs('jpg')) {
// avoid error "geometry does not contain image (unable to crop image)" - gh-17
var index = this._in.indexOf('-size');
@ -798,7 +798,10 @@ module.exports = function (proto) {
}
}
return this.out("-crop", w + "x" + h + "+" + (x || 0) + "+" + (y || 0) + (percent ? '%' : ''));
// backward compatibility
arg = (arg === true) ? '%' : arg;
return this.out("-crop", w + "x" + h + "+" + (x || 0) + "+" + (y || 0) + (arg || ''));
}
// http://www.graphicsmagick.org/GraphicsMagick.html#details-magnify

@ -17,6 +17,13 @@ module.exports = function (gm, dir, finish, GM) {
var args2 = m2.args();
assert.equal('200x155+300+0%', args2[3]);
var m3 = GM(dir + '/image.png')
.crop(200, 155, 300, 0, '!');
var args3 = m3.args();
assert.equal('200x155+300+0!', args3[3]);
if (!GM.integration)
return finish();

Loading…
Cancel
Save