・モジュールのバージョン
perl -M[モジュール名] -e 'print "[モジュール名]::VERSION¥n"'
・古くなっているモジュールの一覧
perl -MCPAN -e 'CPAN::Shell->r'
・古くなっているモジュールを一斉更新
perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'
Translate
2010年10月2日土曜日
use Imager;
使い方を調べてみる。
■画像サイズを調べる
■画像サイズを半分にして別名で保存する
■画像サイズを4分の1にして別名でjpg→pngで保存する
■別の画像を右下に合成する
■画像サイズを調べる
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Imager;
my $img = Imager->new;
$img->read( file=>'images.jpg' ) or die $img->errstr;
my $img_x = $img->getwidth();
my $img_y = $img->getheight();
print "width: $img_x, height: $img_y \n";
■画像サイズを半分にして別名で保存する
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Imager;
my $img = Imager->new;
$img->read( file=>'images.jpg' ) or die $img->errstr;
my $img_x = $img->getwidth();
my $img_y = $img->getheight();
#オブジェクトを上書き
$img = $img->scale( xpixels => $img_x/2, ypixels => $img_y/2 );
$img->write( file => 'half.jpg' ) or die $img->errstr;
■画像サイズを4分の1にして別名でjpg→pngで保存する
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Imager;
#サイズを4分の1にして、jpgからpngに変換する
my $img = Imager->new;
$img->read( file=>'images.jpg' ) or die $img->errstr;
my $img_x = $img->getwidth();
my $img_y = $img->getheight();
$img = $img->scale( xpixels => $img_x/4, ypixels => $img_y/4 );
$img->write( file => 'quarter.png' ) or die $img->errstr;
■別の画像を右下に合成する
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Imager;
my $img = Imager->new;
$img->read( file=>'images.jpg' ) or die $img->errstr;
my $img_x = $img->getwidth();
my $img_y = $img->getheight();
my $img2 = Imager->new;
$img2->read( file=>'half.jpg' ) or die $img2->errstr;
my $img2_x = $img2->getwidth();
my $img2_y = $img2->getheight();
$img = $img->paste(
left => $img_x - $img2_x,
top => $img_y - $img2_y,
img => $img2,
);
$img->write( file => 'mix.jpg' );
2010年9月23日木曜日
2010年9月20日月曜日
Mac OS X ver10.5 emacsを最新の入れてみる。
ひとまず、最新はどれか確認してみる
→http://ftp.gnu.org/pub/gnu/emac/
23.2ね。
$curl -O http://ftp.gnu.org/pub/gnu/emacs/emacs-23.2.tar.gz
$tar xvf emacs-23.2.tar.gz
$cd emacs-23.2
ターミナル用としてビルドする
$./configure --without-x
$make
$sudo make install
このままだと古いバージョンを開いてしまうので・・・
aliasを設定する。
zshを使っているので.zshrcに
alias emacs='/usr/local/bin/emacs-23.2'
と書き足してみる
→http://ftp.gnu.org/pub/gnu/emac/
23.2ね。
$curl -O http://ftp.gnu.org/pub/gnu/emacs/emacs-23.2.tar.gz
$tar xvf emacs-23.2.tar.gz
$cd emacs-23.2
ターミナル用としてビルドする
$./configure --without-x
$make
$sudo make install
このままだと古いバージョンを開いてしまうので・・・
aliasを設定する。
zshを使っているので.zshrcに
alias emacs='/usr/local/bin/emacs-23.2'
と書き足してみる
Mac OS X ver10.5にwgetをいれてみる
今最新いくつなんだろ?
→ttp://ftp.gnu.org/pub/gnu/wget
ということで、wget-1.12が最新らしーので。
$curl -O http://ftp.gnu.org/pub/gnu/wget/wget-1.12.tar.gz
$wget-1.12.tar.gz
$cd wget-1.12
$ sudo ./configure
$ sudo make
$ sudo make install
→ttp://ftp.gnu.org/pub/gnu/wget
ということで、wget-1.12が最新らしーので。
$curl -O http://ftp.gnu.org/pub/gnu/wget/wget-1.12.tar.gz
$wget-1.12.tar.gz
$cd wget-1.12
$ sudo ./configure
$ sudo make
$ sudo make install
登録:
投稿 (Atom)