OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.4k stars 2.39k forks source link

ImageSharp resizing creates images with a blank bottom #15064

Open Skrypt opened 8 months ago

Skrypt commented 8 months ago

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).

Piedone commented 8 months ago

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

image

Skrypt commented 8 months ago

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

fake-is

Piedone commented 8 months ago

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

Skrypt commented 8 months ago

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

Piedone commented 8 months ago

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.

sebastienros commented 8 months ago

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

Skrypt commented 8 months ago

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.