Page 1 of 1

Simple GIF Cropping Problem

Posted: 2009-07-20T05:44:29-07:00
by doubleg
Hello,

I am calling a single IM command in Perl to crop an animated GIF. After "cropping" the resulting image is still the same size. Rather than cropping, the IM command appears to have cleared the background everywhere except the cropped region. The original image and resulting image are at the following links:

(original) http://www.twopalm.com/im/test.gif

(cropped) http://www.twopalm.com/im/crop.gif

Here is the script I used that shows the cropping command issued:

Code: Select all

#!/usr/bin/perl

use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser); 

my $htmldir = "/var/www/vhosts/twopalm.com/httpdocs/";
my $testdir = $htmldir.'im/';

my $cropx = 100;
my $cropy = 100;
my $cropw = 100;
my $croph = 100;


my $origfile = $testdir.'test.gif';
my $cropfile = $testdir.'crop.gif';
my $result = system("/usr/bin/convert", "$origfile", "-crop", "$cropw x $croph + $cropx + $cropy\!", "$cropfile");


print "Content-Type: text/html; charset=utf-8\n\n";
print "$result\n";
exit;
Can anyone see where I'm going wrong here. Thanks!

Re: Simple GIF Cropping Problem

Posted: 2009-07-20T07:28:01-07:00
by doubleg
Hmmm, after searching around the web, I found someone suggesting "+repage". The following appears to have solved it:

my $result = system("/usr/bin/convert", "$origfile", "-crop", "$cropw x $croph + $cropx + $cropy\!", "+repage", "$cropfile");

Re: Simple GIF Cropping Problem

Posted: 2009-07-20T20:36:16-07:00
by anthony
Their is a perl magick solution to somewhere in the forums