Imagerについて

ImagerとはPerlの画像処理用モジュールです。

画像処理を行なう為に必要な基本的な処理、各種フォーマットの画像入出力関数、基本的な画像処理関数などが提供されています。

インストール方法

UNIX系

$ cpan install Imager

とか、場合によっては

$ sudo cpan install Imager

など

Windowsとか

CygwinとかActivePerlでどうにかして下さい。

基本的な使い方

#!/usr/bin/perl -w
use strict;
use warnings;
use Image;

my $img = Imager->new();
$img->read( file=>'lena.png' )
  or die "Cannot read: ", $img->errstr;

$img->write( file=>'lena.jpg' )
  or die "Cannot write: ",$img->errstr;

便利な機能

画像に文字書けます。

my $font = Imager::Font->new(file=>"foo.ttf");
$img->string(x => 50, y => 70,
             string => "Hello, World!",
             font => $font,
             size => 30,
             aa => 1,
             color => 'white');

その他の便利機能

ここ参照。