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
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
Hello
the resized picture are made by calling i.php, if it helps
Offline
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
Any ideas out there? Before I start making changes in the piwigo core files...
Offline
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
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
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
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
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