Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 60624
Status: open
Priority: 80/
Queue: Imager

People
Owner: Nobody in particular
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.77
Fixed in: (no value)



Subject: add an auto_crop() method
# remove rectangular regions matching the top left pixel # on left/top/right/bottom and remove them in a new image my $new = $im->auto_crop(); # with some smarts for handling alpha=0 # return how much was removed my ($new, $left, $top, $right, $bottom) = $im->auto_crop; # crop until we see $color my $new = $im->auto_crop(keep => $color); # instead of the top left pixel, use $color my $new = $im->auto_crop(remove => $color);
I made the code to do that stuff with imager, as a standalone script and inline C: https://gist.github.com/jussikinnula/508bbd57abbe69d47f8e On Mon Aug 23 00:19:57 2010, TONYC wrote: Show quoted text
> # remove rectangular regions matching the top left pixel > # on left/top/right/bottom and remove them in a new image > my $new = $im->auto_crop(); > # with some smarts for handling alpha=0 > > # return how much was removed > my ($new, $left, $top, $right, $bottom) = $im->auto_crop; > > # crop until we see $color > my $new = $im->auto_crop(keep => $color); > > # instead of the top left pixel, use $color > my $new = $im->auto_crop(remove => $color);
I actually was able to use the Imager's "getpixel" method to make a pure Perl version of the gist: https://gist.github.com/jussikinnula/b579938bd2a36e743b02 On Wed Nov 18 10:06:14 2015, SPOT wrote: Show quoted text
> I made the code to do that stuff with imager, as a standalone script > and inline C: > > https://gist.github.com/jussikinnula/508bbd57abbe69d47f8e > > On Mon Aug 23 00:19:57 2010, TONYC wrote:
> > # remove rectangular regions matching the top left pixel > > # on left/top/right/bottom and remove them in a new image > > my $new = $im->auto_crop(); > > # with some smarts for handling alpha=0 > > > > # return how much was removed > > my ($new, $left, $top, $right, $bottom) = $im->auto_crop; > > > > # crop until we see $color > > my $new = $im->auto_crop(keep => $color); > > > > # instead of the top left pixel, use $color > > my $new = $im->auto_crop(remove => $color);