0

here is my whole code:

var fs = require('fs')
  , gm = require('gm');

// resize and remove EXIF profile data
gm('./image.jpg')
.resize(240, 240)
.noProfile()
.write('./image2.jpg', function (err) {
  if (!err) { console.log('done') } else { console.log(err); } ;
});

I have also installed imageMagick. But when I run that simple code I get this silly error:

Error: Could not execute GraphicsMagick/ImageMagick: gm "convert" "./image.jpg" "-resize" "240x240" "+profile" "\"*\"" "./image2.jpg" this most likely means the gm/convert binaries can't be found
    at ChildProcess.<anonymous> (C:\Users\ali\Desktop\Node js\Uploader\node_modules\gm\lib\command.js:232:12)
    at emitOne (events.js:96:13)
    at ChildProcess.emit (events.js:188:7)
    at ChildProcess.cp.emit (C:\Users\ali\Desktop\Node js\Uploader\node_modules\cross-spawn\lib\enoent.js:36:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)

I have also gone ahead into imageMagick website and download and install imageMagick.(ImageMagick-7.0.4-6-Q16-x64-dll.exe HTTP)

and this is my project structure: My project structure That is all! Would U please tell me where is the problem?

Joseph
  • 1,676
  • 2
  • 10
  • 20
  • is GraphicsMagick/ImageMagick installaed on the server you are running this as a global package? – Asif Saeed Jan 31 '17 at 16:40
  • You can try this great module for resizing aswell https://github.com/oliver-moran/jimp. this one is super simple to integrate – Asif Saeed Jan 31 '17 at 16:41
  • I tried Jimp, but it has a big problem: when I resize an image to be 1200 * 800, it will reduce its size down to 700KB, but when I resize the same image with same width and height with another package or paint application(win), it will reduce its size down to 90KB! And that 2 image have identical details and quality. Do U know where the problem is? – Joseph Feb 01 '17 at 12:15
  • you have set the quality to 100? – Asif Saeed Feb 01 '17 at 16:33
  • Thanks! I fixed that, it should be 20. I do really appreciate your help. – Joseph Feb 01 '17 at 17:06

0 Answers0