node.js - gm convert unable to open file ...[NO such file or directory]
typecho
typecho 2017-06-27 09:18:16
0
1
1585

Use gm to read the image, the path is correct,
Error report: gm convert unable to open file ...[NO such file or directory]

router.js

//path.join(__dirname,'../avatar/',filename)等价于 ==c:\users\MrsH\Desktop\codeth\shuoshuo\router\avatar\uestcw.jpg 所以路径是没有问题,图片存在可以无法读取并修改 gm(path.join(__dirname, '../avatar/', filename)) .crop(w,h,x,y) .resize(100,100,"!") .write(path.join(__dirname, './avatar/', filename),function(err){ if(err){ console.log(err) res.send("-1"); return; } res.send("1"); });

The following is the document tree

typecho
typecho

Following the voice in heart.

reply all (1)
滿天的星座
//写成这样没错 gm(path.join(__dirname,'../models','pic08.jpg')) .crop(100,100,100,100) .resize(50,50,'!') .write('./a.jpg', (err)=>{ if(err) console.log(err); console.log('finished'); }) //当我把write的路径改为以下时,报错 path.join(__dirname,'./models','pic08.jpg') //改成这样是对的 path.join(__dirname,'models','pic08.jpg')

So when path.join is used in the future, it means that files in the current directory should not be added./

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!