Jump to content

Transparent animated GIF flashing with Imagemagick (solved)


Linguica

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:

mecha3.gif.5b1d635d2807155e52416cc1f7a06ad9.gif

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

mecha3.thumb.gif.30465b41e3c8c0eadf61b678ca786f6a.gif.7463b162e12e1e5f5b3b17807c7bd7ad.gif

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

Quote

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

Archived

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

  • Recently Browsing   0 members

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