Simple GIF Cropping Problem

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
doubleg

Simple GIF Cropping Problem

Post 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!
doubleg

Re: Simple GIF Cropping Problem

Post 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");
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Simple GIF Cropping Problem

Post by anthony »

Their is a perl magick solution to somewhere in the forums
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply