IImageresizer cache images?

Hi.

We’ve recently implemented the IImageResizer plugin into a project and modified the compression quality. Seems like the function is not being triggered allways. “Old” images, doesnt get compressed with the new quality. It only works when updating or adding images.
Are the images cached on the server somehow? Do we need to run something to clear it to get a new compressed image?

Best regards,
Simon

When an image is resized, a copy of it will be saved on disk. As long as an image of the right dimensions already exist it won’t create a new one, until the file is updated.

You could run a PowerShell script to delete all the generated files to ensure that they’re re-created the next time.

Make sure to create a backup of your files before running this!

# Place this file in the files-directory and run the script.

# Configure to run in folder where the current script-file is located
$filesDirectory = $PSScriptRoot 

# From the folder /Storage/MediaArchive delete all files ending with a duplicate file-ending, filename samples:
# Original: 3a00849f-1706-491e-93dc-8093e905ea0e.jpg
# Scaled version: 3a00849f-1706-491e-93dc-8093e905ea0e.280-210-0-jpg.Jpeg.jpg
# Scaled version: 3a00c8ac-6da7-4461-9f2a-a967b1c85b0e.1200-900-0-jpg.Jpeg
$deleteStorageFileTypes = @("*-jpg.Jpeg.jpg", "*-jpg.Jpeg", "*-png.png")
Get-ChildItem "$($filesDirectory)\Storage\MediaArchive" -recurse -include $deleteStorageFileTypes | remove-item

Thanks @NilsN! I’ll try it out and get back to you :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.