sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Is sharp using cache when an image is resized?

Open kushubham9 opened this issue 8 years ago • 3 comments

I am facing this strange thing. Say I have a given image at location '/something/image.png'.

Now I update the image at the above location and resize the image a multiple times. await sharp(inputFile).resize(width, height).toFile(destinationFile)

What I am observing here, that the resized image somehow still refers to my old image. The new image is not resized.

This is pretty strange to me. Any workaround here?

kushubham9 avatar Oct 23 '18 16:10 kushubham9

Hello, input images are cached - see cache.

The input and output file paths cannot be the same and toFile is asynchonous. Is there code not shown here that could also be modifying destinationFile? Are you able to provide a complete, standalone example that fails in this manner?

lovell avatar Oct 23 '18 18:10 lovell

Also ran into this problem. Perhaps it is worth adding a mention of a cache to the main README.md file?

EvgeniyGorbachev avatar Nov 07 '18 10:11 EvgeniyGorbachev

@kushubham9 I hope this answered your question.

lovell avatar Nov 19 '18 20:11 lovell