Gif resizing breaks animation #436

Open
opened 2026-10-04 23:58:20 +02:00 by adam · 8 comments
Owner

Upload any gif to piwigo and then try to view it at a size smaller then the original in the gallery. As you can see, only the first frame is shown for all sized smaller then the original.

This is rather annoying as the original is sometimes way oversized (sometimes being 60MB mainly because of the amount of frames it has).

Being forced to replace each of these after going to another site to resize them shouldn't have to be done. At this point in time piwigo imho does not properly support gif files unti it can resize them without completely breaking the animation.

Upload any gif to piwigo and then try to view it at a size smaller then the original in the gallery. As you can see, only the first frame is shown for all sized smaller then the original. This is rather annoying as the original is sometimes way oversized (sometimes being 60MB mainly because of the amount of frames it has). Being forced to replace each of these after going to another site to resize them shouldn't have to be done. At this point in time piwigo imho does not properly support gif files unti it can resize them without completely breaking the animation. <!-- github-sync-id:145944143 -->
Author
Owner

I remember this problem. Which graphic library do you use? (it is written on the administration home page).

I remember this problem. Which graphic library do you use? (it is written on the administration home page). <!-- github-comment-id:205744384 -->
Author
Owner

Graphics Library: ImageMagick 6.8.9-9

I do know that ImageMagick Supports a rather wide range of extensions as opposed to GD and produces better quality images but at the same time why is it breaking my gif lol.

Graphics Library: ImageMagick 6.8.9-9 I do know that ImageMagick Supports a rather wide range of extensions as opposed to GD and produces better quality images but at the same time why is it breaking my gif lol. <!-- github-comment-id:205751441 -->
Author
Owner

Just gonna say this https://github.com/Piwigo/Piwigo/issues/456 @plegall

And as for gif's smaller than 10-5MB well you still haven't provided me with a solution to my problem ;P

Just gonna say this https://github.com/Piwigo/Piwigo/issues/456 @plegall And as for gif's smaller than 10-5MB well you still haven't provided me with a solution to my problem ;P <!-- github-comment-id:211003293 -->
Author
Owner

Thread resurrection :-)

I have managed to update image.class.php such that animated gifs are still animated after resizing. See https://github.com/ThomasDaheim/piwigo-stuff/tree/master/animatedgifs.

Unfortunately, I can test my changes only for the case of image_ext_imagick and not for image_imagick. So I could create a pull request for that that would solve half of the issue.

Thread resurrection :-) I have managed to update image.class.php such that animated gifs are still animated after resizing. See https://github.com/ThomasDaheim/piwigo-stuff/tree/master/animatedgifs. Unfortunately, I can test my changes only for the case of image_ext_imagick and not for image_imagick. So I could create a pull request for that that would solve half of the issue. <!-- github-comment-id:305580820 -->
Author
Owner

I've received a request on this very subject today and I think it would be a good idea to :

  • avoid using GD to resize a GIF
  • being able to have a threshold (in pixels) below which animation is not kept
I've received a request on this very subject today and I think it would be a good idea to : - avoid using GD to resize a GIF - being able to have a threshold (in pixels) below which animation is not kept <!-- github-comment-id:1404824209 -->
Author
Owner

I'm still using my solution (see above) to handle animated gifs with imagick or ext_imagick.

Not sure if there are still installations where only GD is available? How would you implement "avoid using GD to resize a GIF" in that case?

I'm still using my solution (see above) to handle animated gifs with imagick or ext_imagick. Not sure if there are still installations where only GD is available? How would you implement "avoid using GD to resize a GIF" in that case? <!-- github-comment-id:1407712925 -->
Author
Owner

I'm still using my solution (see above) to handle animated gifs with imagick or ext_imagick.

Not sure if there are still installations where only GD is available? How would you implement "avoid using GD to resize a GIF" in that case?

Can you go through your solution for me? I saw this as well as your thread on Piwigo forum but I can’t seem to get it working for imagick (not ext) I confirmed “Graphics Library: ImageMagick 7.1.1-26” and I replaced image.class.php with your version and something definitely changes but not for the best. After that when I resize the resized gifs still don’t animate and instead of showing the regular still image it shows the still image with a lot of the pixels being white. Is there another step I’m supposed to do besides replacing image.class.php? In your forum you mention coming up with a new conversion command.

> I'm still using my solution (see above) to handle animated gifs with imagick or ext_imagick. > > Not sure if there are still installations where only GD is available? How would you implement "avoid using GD to resize a GIF" in that case? Can you go through your solution for me? I saw this as well as your thread on Piwigo forum but I can’t seem to get it working for imagick (not ext) I confirmed “Graphics Library: ImageMagick 7.1.1-26” and I replaced image.class.php with your version and something definitely changes but not for the best. After that when I resize the resized gifs still don’t animate and instead of showing the regular still image it shows the still image with a lot of the pixels being white. Is there another step I’m supposed to do besides replacing image.class.php? In your forum you mention coming up with a new conversion command. <!-- github-comment-id:1935313569 -->
Author
Owner

Long time since I had a look at this myself...

I'm still running 13.8.0 - didn't find the time to update yet. But it still works for me. I have now updated the image.class.php in my repro to that version. Graphics is External ImageMagick 6.9.11-60

There is really not much change for animated gifs in the processing. The most code is to be able & handle animated gifs properly:

function __construct: identify animated gifs by checking number of images that are contained in the file
static function get_library: enabled handling of gifs
function write: disabled interlacing and optimize layers for animated gifs <- interlacing is the ciritcal thing, I believe to remember it would also work without optimizing but has flickers

Long time since I had a look at this myself... I'm still running 13.8.0 - didn't find the time to update yet. But it still works for me. I have now updated the image.class.php in my repro to that version. Graphics is External ImageMagick 6.9.11-60 There is really not much change for animated gifs in the processing. The most code is to be able & handle animated gifs properly: `function __construct`: identify animated gifs by checking number of images that are contained in the file `static function get_library`: enabled handling of gifs `function write`: disabled interlacing and optimize layers for animated gifs <- interlacing is the ciritcal thing, I believe to remember it would also work without optimizing but has flickers <!-- github-comment-id:1950243190 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#436