Jump to content

Transparent animated GIF flashing with Imagemagick (solved)


Recommended Posts

I ran into + solved this issue today, but I always like to write these sorts of things down for posterity in case I need to refer to it in the future or if someone else searches for the same issue and comes across this thread.

A user on my forum wanted to use the following animated GIF as his avatar:


But when he uploaded it and it was processed by Imagemagick, the resulting thumbnail version looked like this (seizure warning for those susceptible):


This is not very useful. I managed to track down in the ImageMagick documentation the following:


The traditional way in ImageMagick to optimize an animation, making the result smaller and faster to download and animate, is to "-deconstruct" its "-coalesce" form. This is no longer recommended. Instead you use should use the General GIF Optimizer.

To make a long story short, IPS uses a "deconstruct" command that Imagemagick supports that is supposed to optimize an animated GIF by only saving the portions of each frame that are actually updated from one frame to the next. Unfortunately it has a known issue with transparent GIFs where parts of the image switch from transparent to opaque or vice versa, resulting in a horrible flashing.

With this in mind, I went into the Imagemagick.php file that controls avatar resizing and so forth, and changed the two instances of deconstructImages() to instead use optimizeImageLayers() and the problem was solved.

If you're having a similar issue this is worth trying out at least.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...