#! /usr/local/bin/perl -s # =============================================================== # mk-index-html # =============================================================== # Usage: ./mk-index-html *.jpg | sh # # 指定されたファイルを merge した merged??.jpg というファイルを # カレントディレクトリに作成する。ついでに、merged??.jpg を # クリッカブルマップとして使用する $HTML というファイルを作成 # する。 .... そういう動作をする shell script を作成する (^_^) # -------------------------------------------------------------- # 注) ImageMagick パッケージの montage コマンドを使用します # ------------------- # 設定項目ここから # ------------------- $HTML = '00index.html'; # 出力される html ファイル $tile_w = 6; # merged file の横の数 $tile_h = 6; # merged file のタテの数 $size_w = 80; # merged file 中の画像サイズ(w) $size_h = 80; # merged file 中の画像サイズ(h) $ofile = 'merged-'; # merged file の名前(1) $ofile_ext = '.jpg'; # merged file の名前(2) $montage = 'montage'; # montage コマンドの名前 $file_pattern = '\.(jpe?g|JPE?G|gif|GIF|png|xbm|xpm)$'; # ------------------- # 設定項目ここまで # ------------------- print "#!/bin/sh\n"; print "# this script file is created by mk-index-html\n"; print "if [ -f $HTML ]; then mv $HTML ${HTML}~ ; fi\n"; print < Image Files

Image Files

__end__ ) > $HTML EOB $tiles = $tile_w * $tile_h; foreach $file ( @ARGV ) { if ( ! -f $file ) { next; } if ( $file !~ /$file_pattern/ ) { next; } push(@files,"\"$file\""); $filen++; if($tiles <= $filen) { &exec_montage; } } if(0 < $filen) { &exec_montage; } print <"; cat README; echo ""; fi cat <<__end__ __end__ ) >> $HTML EOB exit; sub exec_montage { $ofilen++; local($tile_hh) = int($#files/$tile_w) + 1; local($com) = "$montage -geometry ${size_w}x${size_h} -tile ${tile_w}x${tile_hh} " . join(" ", @files) . " ${ofile}${ofilen}${ofile_ext}"; if($mode !~ /silent/) { print "echo \'#\' $com\n"; } print "$com\n"; # # print "(\ncat <<__end__\n\n"; local($w,$h); foreach $i ( 0 .. $#files ) { local($x1) = $w * $size_w; local($y1) = $h * $size_h; local($x2) = $x1 + $size_w; local($y2) = $y1 + $size_h; $w++; if($tile_w <= $w) { $h++; $w = 0; } $files[$i] =~ s/([ \t\~\%\#\(\)\:])/sprintf("%%%02x",unpack("C",$1))/eg; print "\n"; } print "\n" . "\"(Index\n" . "__end__\n) >> $HTML\n"; $filen = 0; undef @files; } $COMM = < ---------------------------------------------------------- EOB