scionoftech / webp-converter

[DEPRECATED] A small node.js library for converting any image to webp file format or converting webp image to any image file format.
MIT License
229 stars 43 forks source link

How do I delete the original file after modification? #46

Closed 79percent closed 2 years ago

79percent commented 2 years ago

How do I delete the original file after modification?

I have a webp file and I want to convert it to JPG and delete the original webp file

My code looks like this

 await sharp('./input.webp').toFile('./out.jpg');
 fs.unlinkSync(path.join(__dirname, './input.webp'));

toFile is effective, but report an error

EBUSY: resource busy or locked, unlink

I try other Image format convert it to JPG

GIF report an error as well

EPERM: operation not permitted, unlink

But JPG and PNG file was deleted as expected

How to delete origin webp or gif file?