-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathROTATE.pl
executable file
·67 lines (57 loc) · 1.38 KB
/
ROTATE.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
use Image::ExifTool qw(:Public);
if ($#ARGV == -1) {
print "usage: ROTATE.pl -i inputdir -r target_resolution\n";
exit;
}
$TARGETRES=0;
for ($arg=0;$arg <= $#ARGV;$arg++)
{
if (@ARGV[$arg] eq "-i")
{
$INDIR=@ARGV[$arg+1];
print "checking directory $INDIR\n";
}
if (@ARGV[$arg] eq "-r")
{
$TARGETRES=@ARGV[$arg+1];
print "target_resolution = $TARGETRES\n";
}
}
#no $INDIR
if ($INDIR eq "") {print "use : -i inputdir to choose the current working dir\n";exit;}
#if ($TARGETRES==0) {print "please specify target resolution\n";exit;}
@images=`find $INDIR -maxdepth 1 | egrep -i \'[.]jpe?g$\'`;
$count=$#images+1;
print "found $count images\n";
$INDIR =~ s/\///;
$OUTDIR="$INDIR\_rotate";
print "outdir = $OUTDIR\n";
$cmd="mkdir $OUTDIR";
print "$cmd\n";
system $cmd;
foreach $input_image (@images)
{
chop $input_image;
@tmp=split(/\//,$input_image);
$fullimage=@tmp[$#tmp];
#identify resx and y
$identify=`identify $input_image`;
@tmp=split(/ /,$identify);
@tmp1=split(/x/,@tmp[2]);
$identifyx=@tmp1[0];
$identifyy=@tmp1[1];
if ($identifyx > $identifyy)
{
$maxpix=$identifyx;
}
else
{
$maxpix=$identifyy;
}
$scaleratio=100*$TARGETRES/$maxpix;
print "$fullimage : $identifyx x $identifyy\n";
$cmd="gmic -i $input_image -rotate -90 -o $OUTDIR/$fullimage";
print "$cmd\n";
system $cmd;
}