rlepigre / ocaml-imagelib

The imagelib library implements image formats such as PNG or PPM
GNU Lesser General Public License v3.0
39 stars 13 forks source link

imagetool: Transparent frame updates #45

Open cfcs opened 3 years ago

cfcs commented 3 years ago

After merging https://github.com/rlepigre/ocaml-imagelib/pull/43 we now have better support for transparency in the GIF format.

The imagetool however should be updated to not paint the background color in transparent pixels in animated GIFs when they are painting on top of an opaque pixel. Basically we should replace transparent pixels in the first frame with the --background color, and after that we should probably skip the painting of transparent pixels.

The NETSCAPE extension (aka "animated GIFs") to the GIF format carries some hints like DO NOT DISPOSE that govern the semantics of whether transparent pixels should yield the previous frame content or revert to a keyframe (like the first frame) or actually be transparent in the output. This needs to be investigated and support implemented.

cfcs commented 3 years ago

NB: Imagemagick doesn't handle this case either, so will need to find an implementation that does to provide a frame of reference.