7

I'm using gm module.This is my code:

gm(picture.path).thumb('250', '180', picture.thumb_path, 100, function (error) {
   if(error) console.log(error);
});

But result size sometimes is 249x180. I need 250x180

xfakehopex
  • 151
  • 1
  • 1
  • 8
  • my guess is that it is sizing the image to retain proportions (not stretch it) and that is the closest final result. probably not helpful, but what are the original image sizes? – rlemon Jul 16 '14 at 13:31
  • Since you already have code that does work, this seems more like a bug that you should bring up with the maintainers of the `gm` module. – loganfsmyth Jul 16 '14 at 17:16
  • original image size is 1280x960 – xfakehopex Jul 17 '14 at 04:20
  • strange all images have size 1280x960.. but after thumb method some image have size 250x180, some 249x180 – xfakehopex Jul 17 '14 at 04:41

1 Answers1

5

I have solved it with this code:

imageMagick(picture.path)
    .resize('250', '180', '^')
    .gravity('center')
    .extent(250, 180)
    .write(picture.thumb_path, function (error) {
       if(error) console.log(error);
});
jox
  • 2,218
  • 22
  • 32
xfakehopex
  • 151
  • 1
  • 1
  • 8