imageflow icon indicating copy to clipboard operation
imageflow copied to clipboard

Support animated gifs with a transparent background

Open mhme2000 opened this issue 1 year ago • 21 comments

Does the library support gifs with a transparent background? Do I have to pass any specific configuration for this to work?

mhme2000 avatar Nov 06 '24 15:11 mhme2000

Original gif example ->
5fa97d9c-59a1-40e2-8831-bc5df357f6d7

GIF served by the app using imageflow-server -> image

mhme2000 avatar Nov 06 '24 16:11 mhme2000

UP! I'm into the same issue here, using the version 0.8.3 (currently the latest).

henriqueholtz avatar Nov 07 '24 12:11 henriqueholtz

UP! I'm having the same problem

Matheus-Sleutjes avatar Nov 07 '24 13:11 Matheus-Sleutjes

Simplest step-by-step guide to reproduce:

Clone this repository and run the project ExampleMinimal, inserting the image passed into the wwwroot folder.

image

image

5fa97d9c-59a1-40e2-8831-bc5df357f6d7

mhme2000 avatar Nov 08 '24 17:11 mhme2000

UP

antoniomelotraycorp avatar Nov 08 '24 20:11 antoniomelotraycorp

UP! Estou com o mesmo problema

gaabrielalex avatar Nov 11 '24 12:11 gaabrielalex

Hey everyone! I’m also having this issue with transparent GIFs. Has anyone found a temporary solution?

GustavoEckart avatar Nov 11 '24 13:11 GustavoEckart

UP! I'm having the same problem =/

HellderCardoso avatar Nov 11 '24 17:11 HellderCardoso

I'll look into this, perhaps it was a regression with a recent update of the gif codec. Can you confirm which versions of Imageflow Runtime (the engine, not server) that you are seeing this with?

On Mon, Nov 11, 2024, 7:16 AM Hellder @.***> wrote:

Up

— Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow/issues/653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH5BMWASHGEWM25JB2D2ADQ77AVCNFSM6AAAAABRJCJZQKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRYGY3TCMJRGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

lilith avatar Nov 12 '24 00:11 lilith

@lilith Could these be packages? I don't have them as a direct dependency, but the dlls are generated after the application is built.

image

image

We only have these two direct dependencies in the project:

Imageflow.Server Version="0.8.3"

Imageflow.Server.HybridCache Version="0.8.3"

mhme2000 avatar Nov 12 '24 12:11 mhme2000

https://www.nuget.org/packages/Imageflow.AllPlatforms/#versions-body-tab

Imageflow.AllPlatforms bundles all the Imageflow.NativeRuntime.* dependencies for you.

The versions of those packages are what matter. If you update Imageflow.AllPlatforms, does the issue persist?

lilith avatar Nov 12 '24 12:11 lilith

@lilith yes, the issue persists.

image

mhme2000 avatar Nov 12 '24 13:11 mhme2000

0.13.2 is the latest, not 0.10, based on the screenshot that's a 2yo version.

lilith avatar Nov 12 '24 13:11 lilith

image

image

@lilith I'm sorry, I sent the wrong printscreen. But the error persists.

mhme2000 avatar Nov 12 '24 16:11 mhme2000

Ok. Can you access /imageflow.debug, share that with me (email is fine), along with the exact image files that are not working for you?

lilith avatar Nov 12 '24 21:11 lilith

Also, some browers make the backgroud white, some black, so make sure you test transparent images against something of a different color.

lilith avatar Nov 12 '24 21:11 lilith

Any updates here?

henriqueholtz avatar Nov 20 '24 19:11 henriqueholtz

I'm looking at a full codec swap which means reimplementing the io bridge.

BTW, animated gifs are complex and each frame mutates a canvas incrementally, and thus any processing means recomputing an optimal delta frame, palette, etc, and there are Edge Cases..

This may take a bit.

On Wed, Nov 20, 2024, 12:41 PM Henrique Holtz @.***> wrote:

Any updates here?

— Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow/issues/653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH66WCYSNOURGPUFM6L2BTQXJAVCNFSM6AAAAABRJCJZQKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBZGQYDMMJUGQ . You are receiving this because you were mentioned.Message ID: @.***>

lilith avatar Nov 22 '24 11:11 lilith

Animated, transparent gifs are an extremely difficult corner case. Specifically, supporting this includes:

  1. Decoding each frame, compositing it against the previous frames while preserving the transparency indexed color, working in indexed mode, and keeping timing and repeat information
  2. Doing all the normal image processing such as resizing, sharpening, effects
  3. Re-quantizing the result while finding a reasonable compromise for transparent pixels, since GIF does not support partial transparency, only opaque or invisible. Palette magic must ensure that there is overlap with the global and prior frame palettes to keep the transparent index consistent.
  4. Since there's no way to mark a pixel as transparent on a frame, only relative to previous frames, to preserve transparency all prior frames must have the same pixel marked as transparent
  5. Diff the current frame and prior frame and crop to the area that is actually different, positioning that rectangle and providing just that area. Re-encoding and attempting to avoid palette bloat, but also not eliminating colors unique to the frame. Doing this optimally is a massive task, even more so if you try to achieve true-color hacking (at the expensive of massive file size).
  6. Encode and compress

I'm estimating the entire encoding pipeline would need to become quite a bit slower to account for this, possibly making real-time difficult. After a few days of working on this, I'm going to put this on the backlog, and suggest that animated AND transparent gifs be an offline task, and consider gifski.

lilith avatar Dec 04 '24 00:12 lilith

Transparency works fine if it's not animated

On Tue, Dec 3, 2024, 5:40 PM Marcos Eckart @.***> wrote:

Does the library support gifs with a transparent background? Do I have to pass any specific configuration for this to work?

— Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow/issues/653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH6LAAZCRYEFFVD35Y32DZFOLAVCNFSM6AAAAABS66M4JGVHI2DSMVQWIX3LMV43ASLTON2WKOZSG4YTMMRYHE4TGOI . You are receiving this because you were mentioned.Message ID: @.***>

lilith avatar Dec 04 '24 01:12 lilith

Okay, got it. Is there any simple way to ignore .gif files in the imageflow middleware? And process this file in another way, without going through the lib?

mhme2000 avatar Dec 04 '24 14:12 mhme2000