DanBloomberg / leptonica

Leptonica is an open source library containing software that is broadly useful for image processing and image analysis applications. The official github repository for Leptonica is: danbloomberg/leptonica. See leptonica.org for more documentation.
Other
1.76k stars 387 forks source link

Animated GIF #626

Closed amitdo closed 2 years ago

amitdo commented 2 years ago

Hi Dan,

https://github.com/tesseract-ocr/tesseract/issues/3369#issuecomment-809680986

I attempted to implement writing of gif anim about 4 years ago, but failed. I left questions for the gif inventor/maintainer, but he did not engage. So I Implemented writing of webp anim instead.

Never tried reading animated gif into a pixa.

And if someone shows me how to tell if a gif file is an animated gif, I'll use it in the gif reader to skip ("not supported") reading. I believe that would mostly solve this issue.

Maybe this example from webp can help:

https://github.com/webmproject/libwebp/blob/36a6eea3bc2871c7f0166193a6fa42241af4a464/examples/gif2webp.c#L275

amitdo commented 2 years ago

I closed this issue because I got no feedback for 3 weeks.

amitdo commented 2 weeks ago

Hi Dan,

It turns out you found the way to detect animated gif back in May 2021.

https://github.com/DanBloomberg/leptonica/commit/9d6265f796b7692e93d6bdabde9f35932f758588.patch

https://github.com/DanBloomberg/leptonica/blob/6551f38d71e18f8647fd7f5ea9ed15890dc2289f/src/gifio.c#L242-L247

Leptonica warns the user if the given gif is animered gif, and process the first page only.

Maybe a better way to handle animated gif is to reject the whole gif file with a proper error message?

DanBloomberg commented 2 weeks ago

I agree. Thanks Amit. The change has been submitted.

amitdo commented 2 weeks ago

https://github.com/DanBloomberg/leptonica/commit/1a4ba7eebef8750912335cbab53080f9c1539e2d

Thanks!