- fixes a regression introduced by the fixes for RT 11972
http://rt.cpan.org/Ticket/Display.html?id=27546
+ - cropping outside the image would return an Imager object with
+ no low-level image object, instead of returning false.
+ Fixed by: Philip Gwyn (Leolo)
+ http://rt.cpan.org/Ticket/Display.html?id=27509
+
Imager 0.58 - 16 May 2007
===========
$self->_set_error("resulting image would have no content");
return;
}
-
+ if( $r < $l or $b < $t ) {
+ $self->_set_error("attempting to crop outside of the image");
+ return;
+ }
my $dst = $self->_sametype(xsize=>$r-$l, ysize=>$b-$t);
i_copyto($dst->{IMG},$self->{IMG},$l,$t,$r,$b,0,0);
#!perl -w
use strict;
-use Test::More tests => 60;
+use Test::More tests => 64;
require "t/testtools.pl";
use Imager;
cmp_ok($warning, '=~', 'void', "correct warning");
cmp_ok($warning, '=~', 't65crop\\.t', "correct file");
}
+
+{
+ my $src = test_oo_img();
+ ok(!$src->crop( top=>1000, bottom=>1500, left=>0, right=>100 ),
+ "outside of image" );
+ cmp_ok($src->errstr, '=~', qr/outside of the image/, "and message");
+ ok(!$src->crop( top=>100, bottom=>1500, left=>1000, right=>1500 ),
+ "outside of image" );
+ cmp_ok($src->errstr, '=~', qr/outside of the image/, "and message");
+}