最新版的代码请见GitHub: https://github.com/thinkhy/PerlNight/tree/master/graphicsMagicTest
######################################################################
# file: gm.pl
# brief: Test tool for exacting image with GraphicsMagick
# author: thinkhy
# date: 11/01/07
######################################################################
use File::Glob ':glob';
use strict;
my @files = glob "D://抽图图片//抽图出错图片189张//*.eps";
my $logfile = "D://抽图图片//抽图出错图片189张//extractImage.log";
sub getTime
{
my $time = shift || time();
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time);
$year += 1900;
$mon ++;
$min = '0'.$min if length($min) < 2;
$sec = '0'.$sec if length($sec) < 2;
$mon = '0'.$mon if length($mon) < 2;
$mday = '0'.$mday if length($mday) < 2;
$hour = '0'.$hour if length($hour) < 2;
my $weekday = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')[$wday];
return { 'second' => $sec,
'minute' => $min,
'hour' => $hour,
'day' => $mday,
'month' => $mon,
'year' => $year,
'weekNo' => $wday,
'wday' => $weekday,
'yday' => $yday,
'date' => "$year-$mon-$mday"
};
}
sub writelog
{
my $str = shift(@_);
open LOG, ">>$logfile" or die "Could not open my.log: $!";;
my $tt = getTime();
my $t = $tt->{'year'}."//".$tt->{'month'}."//".$tt->{'day'}." $tt->{'hour'}:$tt->{'minute'}:$tt->{'second'} ";
print LOG $t.": ".$str;
close LOG;
}
my $file;
my $fault = 0;
#foreach $file (in $files)
my $cnt = @files;
print "共转换".$cnt."个文件/n/n";
foreach(@files)
{
my $src = $_;
chomp($src);
my($dirpath,$basename,$extname) = ($src =~ /^((?:.*[:////])?)(.*)(/.[^.]*$)/s);
my $outputFile = $dirpath.$basename.".jpg";
print $outputFile."/n";
my $cmd = "gm convert "."/"".$src."/""." ".$outputFile;
print $cmd;
my $result = `$cmd`
or { $fault++, writelog($src." 抽取失败/n")};
print $result;
}
print "共转换文件".$cnt."个,转换成功:".($cnt-$fault)."个/n";
__END__
分享到:
相关推荐
In this inspiring book, Ash Maurya takes you through an exacting strategy for achieving a "product/market fit" for your fledgling venture, based on his own experience in building a wide array of ...
The InstallShield East and West Language Packs localize your installations according to Microsoft‘s exacting translation guidelines, eliminating hundreds of hours of installation dialog and message ...
It offers full-featured file and directory access with flexible device and volume management including support for partitions. Source Code: µC/FS is provided in ANSI-C source to licensees. The ...
This Study Guide was developed to meet the exacting requirements of today's certification candidates. In addition to the consistent and accessible instructional approach that has earned Sybex the ...
.| || The InstallShield East and West Language Packs localize your || installations according to Microsoft‘s exacting translation || guidelines, eliminating hundreds of hours of installation dialog ...
喜欢词根记忆的朋友可以试一下,很清晰的电子书 2.act=to do,to drive,表示...exacting 苛求的(exact+ing) interact 相互作用(inter相互+act→相互动→相互作用) react 反应;反抗(re反+act→反动;反应)