简体   繁体   中英

Error: Command failed: convert: unable to open image - Node, express, imagemagick

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.

请将您的相对路径gm('images / black-yellow-simple-lady-woman.jpg')更改为绝对'/home/user/meteorproject/public/images/black-yellow-simple-lady-woman.jpg'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM