
I am trying to delete file when a image is resized and exported to a file. But the original image can not be deleted using node.js fs function unlink or unlinkSync.
Is there any functionality in sharp where we can command sharp to done processing a file?
Hello, please see #346 and http://sharp.dimens.io/en/stable/api/#sharpcacheoptions
@lovell Thank you so much. That helped. But just asking, is caching necessary or is there any special use case?
Caching is useful if you'll be processing the same input image a few times in quick succession, e.g. to generate multiple output dimensions. Caching is the default behaviour of libvips, although the default values used by sharp are slightly lower.
@lovell Hi, sorry, this might be silly question. Is there any way we can clear the cache manually? Because keeping a file in memory can be useful for generate multiple output dimensions but as soon as we done with it, we can free the memory and delete original file.
sharp.cache(false) will clear it.
@lovell wow... I though false disables all the caching but did not know clears it as well. Thank you.
Thanks for the feedback - hopefully clarified by 99f960b
Most helpful comment
Caching is useful if you'll be processing the same input image a few times in quick succession, e.g. to generate multiple output dimensions. Caching is the default behaviour of libvips, although the default values used by sharp are slightly lower.