0

I'm trying to resize images before serving them to the client. Inside my public directory I have the directory images. All images are being served to different pages successfully with unique permalinks. http://localhost:3000/post/+permalink. I npm installed gm, imagemagick, and tried brew install imagemagick as well. I have this in my routes files:

        var p = 'post/'+permalink
        console.log(p);
        var fs = require('fs');
        var gm = require('gm').subClass({ imageMagick: true });

        gm('images/black-yellow-simple-lady-woman.jpg')
        .resize(234, 567)
        .autoOrient()
        .write(p, function (err) {
          if (err) console.log(' noooo! '+err);
        });




 Error: Command failed: convert: unable to open image `images/black-yellow-simple-lady-woman.jpg': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: no images defined `post/ribs_52977588145822' @ error/convert.c/ConvertImageCommand/3127.
3
  • What's the directory structure of your project? You can try calling gm() with the absolute image path. Commented Mar 8, 2014 at 6:18
  • 1
    The path was incorrect. I needed to add public. i'm deeply ashamed of myself. Commented Mar 8, 2014 at 21:26
  • I just had a similar 'embarrassing' situation: I was trying to save the image to 'public/images/folder_1/image.png', however, 'folder_1' didn't exist and hence I was getting your error. With this comment I am just trying to emphasise the importance of checking that the entire path is valid. In relation to this, see the following module which can be useful: stackoverflow.com/a/13696975/1972495 Commented Sep 3, 2014 at 5:39

1 Answer 1

2

Please change your relative path gm('images/black-yellow-simple-lady-woman.jpg') to absolute '/home/user/meteorproject/public/images/black-yellow-simple-lady-woman.jpg'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.