This queue is for tickets about the Imager CPAN distribution.

Maintainer(s)' notes

Tickets for Imager are now on github at https://github.com/tonycoz/imager

Report information
The Basics
Id:
27509
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
perl [...] pied.nu
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.55
Fixed in:
(no value)



Subject: crop outside of an image
Say the image is 100x100, if you crop outside the image, ->crop returns an empty image (ie, one w/o ->{IMG}) but not undef $src->crop( top=>1000, bottom=>1500, left=>0, right=>100 ) diff -rub Imager-0.54.ORIG/Imager.pm Imager-0.54/Imager.pm --- Imager-0.54.ORIG/Imager.pm 2006-09-14 03:30:23.000000000 -0400 +++ Imager-0.54/Imager.pm 2007-06-08 16:35:17.000000000 -0400 @@ -754,7 +754,10 @@ $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); diff -rub Imager-0.54.ORIG/t/t65crop.t Imager-0.54/t/t65crop.t --- Imager-0.54.ORIG/t/t65crop.t 2006-08-07 02:37:35.000000000 -0400 +++ Imager-0.54/t/t65crop.t 2007-06-08 16:42:05.000000000 -0400 @@ -1,7 +1,7 @@ #!perl -w use strict; use lib 't'; -use Test::More tests => 60; +use Test::More tests => 64; require "t/testtools.pl"; use Imager; @@ -171,3 +171,13 @@ 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"); +}
On Fri Jun 08 16:47:27 2007, GWYN wrote:
Show quoted text
> Say the image is 100x100, if you crop outside the image, ->crop returns > an empty image (ie, one w/o ->{IMG}) but not undef
Thanks, applied to subversion. I just had a regression reported in 0.58, so I'll be doing a 0.59 very soon with your fix. Tony
On Fri Jun 08 16:47:27 2007, GWYN wrote:
Show quoted text
> Say the image is 100x100, if you crop outside the image, ->crop returns > an empty image (ie, one w/o ->{IMG}) but not undef
Imager 0.59 has been released with your patch included. Thanks for your report and patch. Tony


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.