Announcement

#1 2016-10-26 17:14:31

TheDoc
Member
Munich / Germany
2015-10-18
173

Support for animated GIFs

Hi,

as discussed in [Forum, topic 26160] Animated gifs Piwigo currently doesn't support animated gifs. It can show the original size gif correctly but the reduced versions under piwigo\_data\i\galleries are not animated anymore.

Since I have managed to resize gifs with ImageMagick and keeping the animation I would be willing to give it a try in Piwigo as well. If someone could give me a pointer where thee transformation is done? A grep on "ImageMagick" yields some hits, I would think that

admin\include\functions_upload.inc.php

is the right place to start?

In addition: Is there any way to trigger that function for a specific image manually? Or would I need to do something like

- remove image
- sync
- add image
- sync

every time?

Thanks,
Thomas

Piwigo version

        Piwigo 2.8.2
Environment
        Operating system: Linux
        PHP: 5.6.27 (Show info) [2016-10-26 17:07:47]
        MySQL: 5.5.52-0+deb7u1-log [2016-10-26 17:07:47]
        Graphics Library: External ImageMagick 6.8.9-9

Offline

 

#2 2016-10-26 17:24:59

TheDoc
Member
Munich / Germany
2015-10-18
173

Re: Support for animated GIFs

Reply to self and for documentation :-)

Have crawled through the code to something like

class image_ext_imagick implements imageInterface

in admin\include\image.class.php

Offline

 

#3 2016-10-27 14:17:54

flop25
Piwigo Team
2006-07-06
7037

Re: Support for animated GIFs

Hello
the resized picture are made by calling i.php, if it helps


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#4 2016-10-31 17:22:11

TheDoc
Member
Munich / Germany
2015-10-18
173

Re: Support for animated GIFs

So now I have found a command line that works for gifs, e.g.:

    convert IMG_7904.gif -coalesce -resize 1280x1280 +dither IMG_7904.resized.gif

I only need to understand where to use it in piwigo :-)

So far I have found two places:

1) functions_upload.inc.php, add_uploaded_file, line 296: $img->pwg_resize: inital resize during upload

    $img->pwg_resize: could easily be extended

2) i.php, line, line 550: $image->resize: create image as requested

    $image->resize: who uses that? can it be extended in all cases? e.g. you might wouldn't want to have animated thumbnails...

Not really sure what the next step would be here :-(

Offline

 

#5 2016-12-06 09:38:46

TheDoc
Member
Munich / Germany
2015-10-18
173

Re: Support for animated GIFs

Any ideas out there? Before I start making changes in the piwigo core files...

Offline

 

#6 2017-02-20 21:46:36

TheDoc
Member
Munich / Germany
2015-10-18
173

Re: Support for animated GIFs

So, finally I have some free cycles to look closer into this...

My understanding is: For animated gif support one would need to extend all three implementations of "imageInterface" in image.class.php:

- image_imagick: some examples that could be re-used in http://php.net/manual/de/imagick.coalesceimages.php

- image_ext_imagick: add something like "convert IMG_7904.gif -coalesce -resize 1280x1280 +dither IMG_7904.resized.gif" to the imagick command

- image_gd: Can't be done? See http://it.php.net/manual/en/function.im … .php#59787

Before going down that road I would really appreciate if someone could comment if this is how it should be done :-)

And additionally: Is there any way to do that as a plugin? Or would I need to have to patch image.class.php directly?

Offline

 

#7 2017-02-25 21:59:11

TheDoc
Member
Munich / Germany
2015-10-18
173

Re: Support for animated GIFs

After some debugging I figured out that for gif files always the gd library is used - independent of the availability of image magick. Does anyone have any idea why this is the case? I fail o see a good reason for that...

Especially, since gd doesn't seem to be able to support animated gifs at all!

For documentation: In image.class.php, get_library there are checks like "$extension != 'gif'" for both the internal and external image magick libraries.

Next attempt would bee to remove the checks for gif format and see what happens...

Offline

 

#8 2017-02-25 23:08:33

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: Support for animated GIFs

TheDoc wrote:

Next attempt would bee to remove the checks for gif format and see what happens...

please do and tell us what happen! I don't remember why this check exists.

Offline

 

#9 2017-02-26 07:53:18

rvelices
Former Piwigo Team
2005-12-29
1960

Re: Support for animated GIFs

I have no idea why we are using one library or another but I think at one point there was some patent/copyright issue with gif format..

Offline

 

#10 2017-02-26 17:18:44

TheDoc
Member
Munich / Germany
2015-10-18
173

Re: Support for animated GIFs

plg wrote:

please do and tell us what happen! I don't remember why this check exists.

Well, you can now see it for yourself :-)

Code: https://github.com/ThomasDaheim/piwigo- … imatedgifs
Gallery: http://www.feuster.com/piwigo/picture?/ … y/786-test

Some questions on my end remain:

- Any way to access $ext_imagick_version of pwg_image from within image_ext_imagick? I currently use an optimization command that requires minimum 6.2.7 <- older "Optimize" could be used if this can't be done easily

- thumbs also get animated, since I can't seem to find out in image.class.php that a thumb should be created <- I could live with that

- I can't test any changes to the image_imagick class, since my php doesn't come bundled... But it shouldn't be too hard to redo my changes from image_ext_imagick for anyone who could also test it

AND this has only been tested with 1-2 images. Hopefully, somewhere exists a big test suit to see if all cases are covered :-)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact