i making image resizer website (it resizes image based on the width of container in).
i can save , server jpeg's , png's cannot seem save .gif's file.
this code works jpg's , png's
sharp(imgpath) .resize(containwidth, null) .withoutenlargement() .tofile(modimgpath, function(err) { if(err){console.log(err)} }); i can gif's display in browser (with code below) cannot save them file.
sharp(imgpath) .resize(modimgpath, null) .withoutenlargment() .tobuffer(function(err, outputbuffer) { if (err) {console.log(err)} } iv looked how save image buffers file nothing seems work.
currently gif output seems unsupported in sharp.
https://github.com/lovell/sharp/issues/162
https://github.com/lovell/sharp/issues/245
one solution, though haven't tried see if works, change output format. save first frame of gif.
Comments
Post a Comment