Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Made a few changes so that you don't have to write to file for cropping #49

merged 2 commits into from

4 participants

Jason Teplitz John bardu Rasmus
Jason Teplitz

I made it so that crop now accepts srcData instead of a srcPath, and won't through an error if you don't send a dstPath, because that way you can send the resulting image to stdout.

Jason Teplitz

Sorry some console logs leaked through there that I forgot to delete.


Exactly what I was looking for, thanks.


I'm guessing this package is no longer supported maintained? Possible you could hand this off to someone else?


Agree, would be nice if someone could take over and further improve this useful package.

Jason Teplitz

Definitely, it's a really nice package and doesn't look like it's been maintained in a while.



Just wondering did you fork this package? If not could you do so and share?


Cool, thanks.

Jason Teplitz

No problem. I've also reached out to rsms on twitter to see if he still plans on maintaing this repo.


@bardu for future reference, jteplitz602 added a pull request to this ticket as you can see from those 2 commit's above. You are always able to grab the code from there or just use that repo instead of this one if the author never accepts the pull request. As in the case of this repo :)

Rasmus rsms merged commit 1e88bac into from

Thanks for being patient guys


thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 7 deletions.
  1. +25 −7 imagemagick.js
32 imagemagick.js
@@ -275,25 +275,43 @@ exports.resize = function(options, callback) {
exports.crop = function (options, callback) {
if (typeof options !== 'object')
throw new TypeError('First argument must be an object');
- if (!options.srcPath)
- throw new TypeError("No srcPath defined");
- if (!options.dstPath)
- throw new TypeError("No dstPath defined");
+ if (!options.srcPath && !options.srcData)
+ throw new TypeError("No srcPath or data defined");
if (!options.height && !options.width)
throw new TypeError("No width or height defined");
+ if (options.srcPath){
+ var args = options.srcPath;
+ } else {
+ var args = {
+ data: options.srcData
+ };
+ }
- exports.identify(options.srcPath, function(err, meta) {
+ exports.identify(args, function(err, meta) {
if (err) return callback && callback(err);
var t = exports.resizeArgs(options),
ignoreArg = false,
+ printNext = false,
args = [];
t.args.forEach(function (arg) {
+ if (printNext === true){
+ console.log("arg", arg);
+ printNext = false;
+ }
// ignoreArg is set when resize flag was found
if (!ignoreArg && (arg != '-resize'))
// found resize flag! ignore the next argument
- if (arg == '-resize')
+ if (arg == '-resize'){
+ console.log("resize arg");
ignoreArg = true;
+ printNext = true;
+ }
+ if (arg === "-crop"){
+ console.log("crop arg");
+ printNext = true;
+ }
// found the argument after the resize flag; ignore it and set crop options
if ((arg != "-resize") && ignoreArg) {
var dSrc = meta.width / meta.height,
@@ -343,7 +361,7 @@ exports.resizeArgs = function(options) {
// normalize options
if (!opt.format) opt.format = 'jpg';
if (!opt.srcPath) {
- opt.srcPath = (opt.srcFormat ? opt.srcFormat +':-' : '-');
+ opt.srcPath = (opt.srcFormat ? opt.srcFormat +':-' : '-'); // stdin
if (!opt.dstPath)
opt.dstPath = (opt.format ? opt.format+':-' : '-'); // stdout
Something went wrong with that request. Please try again.