OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

ImageSharp resizing creates images with a blank bottom

Open Skrypt opened this issue 2 years ago • 7 comments

Sometimes ImageSharp doesn't finish to process / resize an image and it produces an image in it's cache with a blank bottom part.

So far, to resolve this issue; we clean up the ImageSharp cache to reinitiate the process to create the cached image.

Having a background task to purge the is-cache periodically would automate that process. Of course, this is not the appropriate fix but at least a tool to use in the mean time.

Another way would be to add a data-attribute on these images that points to the actual image-cache folder to be able to remove them with an admin tool on frontend UI. Basically, each images that are resized by ImageSharp, we should be able to purge the cached item without needing to find it in the is-cache folder (almost impossible).

Skrypt avatar Jan 11 '24 17:01 Skrypt

Do you have some kind of a repro? What we see on the OC homepage might be this?

image

Piedone avatar Jan 11 '24 18:01 Piedone

Here, I can't repro that quick but it would look more like this:

fake-is

Skrypt avatar Jan 11 '24 19:01 Skrypt

Are you using Azure Blob Storage? Because then https://github.com/OrchardCMS/OrchardCore/issues/15016 might help.

Piedone avatar Jan 11 '24 19:01 Piedone

Yeah, this website fetches the original image from an Azure Blob Storage account.

Skrypt avatar Jan 11 '24 19:01 Skrypt

Then I suggest you make a try with the prototype code I added under the issue (or the cleaner one under the PR) and see if it helps.

Piedone avatar Jan 11 '24 19:01 Piedone

Is that a bug in ImageSharp or Orchard? Have you managed to explain what triggers it?

sebastienros avatar Feb 08 '24 18:02 sebastienros

To be honest, no, I couldn't find why it was happening. Either it was failing to download entirely the image from the blob storage because it was not entirely uploaded (which I would be surprised of). Or, a network issue happened in the middle of the resize of this image by ImageSharp which is totally arbitrary.

The issue is not really there. I think you can't prevent this from happening because of ... weather ... The thing I would like though is to be able to find and purge this image from the ImageSharp cache easily instead of purging it entirely.

Skrypt avatar Feb 08 '24 18:02 Skrypt