sharp icon indicating copy to clipboard operation
sharp copied to clipboard

v0.33: not sucessfully closing file access on previewImage exported with Exiftool from RAW

Open ToxicToxster opened this issue 2 years ago • 3 comments

I'm running a node.JS Script that uses exiftool to extract JpgFromImage for Sony Alpha 7 IV RAWs and extract previewImage from Sony Alpha 7 III RAWs. I run this with an Electron Frontend. After creating the JPEGs from the RAWs I run the following code: const resizeAndSaveImage = async (fromRawFilePath, targetFilePath, rotationAngle) => { await sharp(fromRawFilePath) .rotate(rotationAngle) .resize(2000) .jpeg() .toFile(targetFilePath); };

With Sharp 0.32.6 there is no problem and I can delete the file in the fromRawFilePath location, but with 0.33 the JpgFromImage is no problem, but the previewImage stays in access and I can't delete it until I close the Electron App. Changing back to 0.32.6 the problem is gone and all files can be deleted.

ToxicToxster avatar Dec 10 '23 18:12 ToxicToxster

You've not provided any information about the OS/platform you're running, but my best guess would be that this is on Windows, therefore you may need to use sharp.cache({ files: 0 }) if you expect to delete input files within the same process.

https://sharp.pixelplumbing.com/api-utility#cache

lovell avatar Dec 10 '23 18:12 lovell

Yes, it's Windows 11. Node.JS 20.10.0. And yes, this change of cache worked. But why did it work until sharp 0.32.6 and doesn't with 0.33?

ToxicToxster avatar Dec 10 '23 19:12 ToxicToxster

There are quite a few moving parts so it's hard to know exactly what changed between versions. I suspect you might simply have got lucky that this never failed previously.

lovell avatar Dec 10 '23 19:12 lovell