The document shows code for processing images using the Imager module in Perl. It demonstrates scaling, cropping, mapping color values, combining images using rubthrough, adding text with QR codes, detecting differences between images, and detecting faces in an image using a cascade classifier. It also includes code to search for adult video actresses from a porn module.
1 of 51
Downloaded 33 times
More Related Content
画像Hacks
5. use strict;
use warnings;
use Imager;
my $file = 'doya.jpg';
my $image = Imager->new( file => $file ) or die Imager->errstr;
$image = $image->scale( xpixels => 100 );
$image->write( file => 'out.jpg' ) or die $image->errstr;
6. ...;
my $image = Imager->new( file => $file ) or die Imager->errstr;
$image = $image->scale( xpixels => 100 );
$image = $image->crop( height => 100 ); #
$image->write( file => 'out.jpg' ) or die $image->errstr;
...;
11. sub get_map {
my $gamma = shift;
my @map =
map { int( 0.5 + 255 * ( $_ / 255 )**$gamma ) } 0 .. 255;
return @map;
}
$image->map(
red => get_map(0.5),
green => get_map(0.65),
blue => get_map(0.8)
);
my $waku = Imager->new( file => 'waku.png' );
$image->rubthrough( src => $waku );