Page 1 of 1

Animated gif, setImagePage incorrect after crop

Posted: 2012-02-27T19:44:47-07:00
by vbaspcppguy
I'm cropping animated GIFs and the result of some of them is incorrect. Everything I've found says that setting the Page should fix it but it doesn't.

Source Image:
Image

Result Image: (Note the extra transparent area)
Image

I've tried:
- setImagePage before coalesceImages
- setImagePage after deconstructImages
- using the setPage function
- Saving the image, loading it again and recropping it (does nothing)
- doing setImagePage(0, 0, 0, 0)
- doing setImagePage(null, null, null, null)

Notes:
- If I also resize the result smaller, things work fine.
- ImageMagick claims the resulting image is the right size.

Details:
Example: http://mafiareturns.com/admin/matt_stuf ... k/crop.php
Source: http://pastebin.com/J02KqTrw

ImageMagick Version: ImageMagick 6.7.5-3 2012-02-24 Q16 http://www.imagemagick.org
PHP Extension Version (Gentoo package): dev-php/pecl-imagick version 3.0.0-r1
OS: Gentoo

Edit://Oops.

Re: Animated gif, setImagePage incorrect after crop

Posted: 2012-02-28T09:37:55-07:00
by vbaspcppguy
I did some testing with the command line tools which I had never used before and was able to get a good image as well as duplicate the results that Imagick is creating.

This one works fine, creates the desired results:

Code: Select all

convert haters-owl.gif -coalesce -crop 100x100+25+25\!  console_test.gif
This one creates an animated gif with extra transparent area on the right and bottom sides:

Code: Select all

convert haters-owl.gif -coalesce -crop 100x100+25+25\! -layers OptimizePlus  console_test.gif
I used the same file in the example in the last post.

Re: Animated gif, setImagePage incorrect after crop

Posted: 2012-02-28T11:12:55-07:00
by fmw42
this sounds similar to the problem reported at viewtopic.php?f=1&t=20227&p=80411&hilit ... ize#p80392. See the whole set of replies, esp, from Anthony. You may need to upgrade your IM version.

Re: Animated gif, setImagePage incorrect after crop

Posted: 2012-02-28T21:53:58-07:00
by DJ Mike
Try setimagepage().

Image
Dimensions 240 x 92
Size 135691 bytes
Number Of Colors 79
Format GIF
Frames 25

Working cropper
http://eclecticdjs.com/mike/wtv/tools/i ... rop_03.php

Source
http://eclecticdjs.com/mike/wtv/tools/i ... rop_03.txt

Needs these to upload and some functions:
http://eclecticdjs.com/mike/wtv/tools/i ... ctions.txt
http://eclecticdjs.com/mike/wtv/tools/i ... upload.txt

Relevent code:

Code: Select all

$image = new Imagick($_SESSION[path]);

##################
if ( $_GET[action] == "Crop" ) 
   {  
    foreach ($image as $frame)
    { $frame->cropimage( $w, $h, $ul_x, $ul_y); }
   }
##################
# Reset geometry
foreach ($image as $frame)
 { $frame->setimagepage( $w, $h, 0, 0); }
 

Re: Animated gif, setImagePage incorrect after crop

Posted: 2012-02-29T15:57:44-07:00
by vbaspcppguy
I use setImagePage, and have tried it everywhere. As I have it now, it does do what its supposed to MOST of the time.