Unable to crop animated gif when gd is not installed #854

Open
opened 2026-10-05 00:20:58 +02:00 by adam · 0 comments
Owner

I was working on issue #957 to allow Piwigo to use External ImageMagick even if GD is not installed.
I modified admin/include/image.class.php by removing condition $extension != 'gif'.

Then I added at line 522:

if ('gif' == strtolower(get_extension($source_filepath)))
{
      $command .= '[0]';
}

This instruction is to select the first frame of the gif to get the right dimension.

Then at the file admin/include/photos_add_direct_prepare.inc.php, I put in comments : $setup_errors[] = l10n('GD library is missing');

This is working perfectly. But a another problem comes when the bootstrap theme tries to crop and resize the gif.

I found some commands to crop and resize correctly:

convert example.gif -coalesce -repage 0x0 -crop widthxheight +x+y +repage -resize 260x179! example.gif

We can also use gifsicle to do the job :

gifsicle --crop x,y+widthxheight --resize-fit 260x179 example.gif > example_cropped.gif

Some gifs can be heavy so we should try to reduce there weight (Gifsicle is better for reducing weight).

I was working on issue #957 to allow Piwigo to use External ImageMagick even if GD is not installed. I modified `admin/include/image.class.php` by removing condition `$extension != 'gif'`. Then I added at line 522: ``` if ('gif' == strtolower(get_extension($source_filepath))) { $command .= '[0]'; } ``` This instruction is to select the first frame of the gif to get the right dimension. Then at the file `admin/include/photos_add_direct_prepare.inc.php`, I put in comments : `$setup_errors[] = l10n('GD library is missing');` This is working perfectly. But a another problem comes when the bootstrap theme tries to crop and resize the gif. I found some commands to crop and resize correctly: `convert example.gif -coalesce -repage 0x0 -crop widthxheight +x+y +repage -resize 260x179! example.gif` We can also use gifsicle to do the job : `gifsicle --crop x,y+widthxheight --resize-fit 260x179 example.gif > example_cropped.gif ` Some gifs can be heavy so we should try to reduce there weight (Gifsicle is better for reducing weight). <!-- github-sync-id:408112018 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#854