Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'2': 'Invalid Parameter - -resize\r\n', #528

Closed
LingboTang opened this issue May 25, 2016 · 7 comments
Closed

'2': 'Invalid Parameter - -resize\r\n', #528

LingboTang opened this issue May 25, 2016 · 7 comments

Comments

@LingboTang
Copy link

LingboTang commented May 25, 2016

I'm running the resize.js example on windows 10 using node. And I got this error:

{ '0':
   { [Error: Command failed: Invalid Parameter - -resize
   ] code: 4, signal: null },
  '1': '',
  '2': 'Invalid Parameter - -resize\r\n',
  '3': 'convert "C:\\Users\\ltang\\Documents\\GitHub\\testMyGM\\imgs\\Balls.jpg" "-resize" "58x50%" "C:\\Users\\ltang\\Documents\\GitHub\\testMyGM\\imgs\\newImage.jpg"' }

And this is how I modified the resize example

var gm = require('gm').subClass({
    imageMagick: true
});

var currentDir = __dirname + "\\imgs";

//var gm = require('gm');

console.log(currentDir);

gm(currentDir + "\\image.jpg").resize(353, 257, "!")
        .autoOrient()
        .write(currentDir+"\\newImage.jpg", 
        function (err) {
            if (!err) console.log(' hooray! '); console.log(err);
    });

Is there anything wrong with my syntax and how can I resolve it?

@LingboTang LingboTang changed the title { [Error: Command failed: Invalid Parameter - /image.jpg ] code: 4, signal: null } '2': 'Invalid Parameter - -resize\r\n', May 26, 2016
@gablabelle
Copy link

@LingboTang I have the same problem ... Did you find a solution ?

    var thumb1280 = task.target.replace('.jpg', '-1280.jpg');

    var resizeThePhotos = function(targetRelativePath) {

        var target = path.join(__dirname, '..', targetRelativePath);

        gm(target)
            .resize('1280')
            .write(thumb1280, function (err) {
                if (!err) {
                    //console.log(target + ': 1280 done');
                }
                else {
                    console.log(target, err);
                }
            });
    };

I get { [Error: Command failed: Invalid Parameter - -resize] code: 4, signal: null }

@LingboTang
Copy link
Author

LingboTang commented Jun 1, 2016

No I didn't fix the original, it must be some syntax problem. But I did some kind of hack, and I made gm successfully thumbnail images in S3 bucket. How I did to make it work is to include imageMagick:

var gm = require('gm').subClass({
    imageMagick: true
});

other than that, you should also define your .resize() function as a function that would be used to define .size():

gm(response).size(function(err, size) {
          var scalingFactor = Math.min(myWidth /size.width, myWidth / size.height);
          var width = scalingFactor * size.width;
          var height = scalingFactor * size.height;
          var index = key;
          this.resize(width, height).toBuffer(
                 'JPG', function(err,
                       buffer) {
                       if (err) {
                           next(err);
                       } else {
                           next(null, buffer, key);
                       }
         });
});

@gablabelle
Copy link

OK ... I reinstalled ImageMagick checking legacy tools got a different error ... so decided set it to false instead of true and it works now.

var gm = require('gm').subClass({imageMagick: false});

@LingboTang
Copy link
Author

LingboTang commented Jun 1, 2016

@gablablle Ok, that's interesting, I don't know where exactly cause the problem. I think there should be some explanation about this. I'll keep this issue here.

@mattbajorek
Copy link

I had a similar issue and had solved the issue by making sure I installed the legacy utilities.

legacyutilities

@madneal
Copy link

madneal commented Sep 16, 2017

@mattbajorek Hi, I have tried to install imgamagick. But I have not seen the install legacy utilities. Which version you have installed, I selected verison ImageMagick-7.0.7-2-Q16-x64-static.exe.

@aheckmann
Copy link
Owner

Fixed by #846. Released in v1.25.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants