1. I need the value of the EXIF:['Orientation']. the code then branches with ... if > 1, do -auto-orient
2. I can get the image specs I want with a compound command in ImageMagick. Here it is:
Code: Select all
$command = "convert -auto-orient -resample 96 -resize \"x640\" -strip $_ converted/$fname.png";
3. I needed to capture the value of EXIF:['Orientation'], and as a numeric. I used ExifTool, which is another tool, separate from ImageMack. Here's the perl script...
Code: Select all
#!/usr/bin/perl -w
use Image::ExifTool qw(:Public);
### [[ http://www.sno.phy.queensu.ca/~phil/exiftool/ExifTool.html ]] ###
while( glob('*.JPG') ) {
my $exifTool = new Image::ExifTool;
my $meta = $exifTool->ImageInfo( $_ ); # required, constructs the ObjectFile:EXIF, or use perl bless()
my $tag = "Orientation";
my $v = $exifTool->GetValue($tag, 'ValueConv'); # reads the exif values, fetches a field, ValueConv as numeric
my $fname = substr( $_, 0, rindex($_, '.') ); # strips the .JPG off the file name
my $command;
if( $v > 1 ) {
$command = "convert -auto-orient -resample 96 -resize \"x640\" -strip $_ converted/$fname.png";
} else {
$command = "convert -resample 96 -resize \"640x\" -strip $_ converted/$fname.png";
}
open IN, "$command |" or die "no run: $!\n";
close IN;
print "converted : $fname\n";
}
Code: Select all
perl exif_magick.pl
Can I gang the options in PerlMagick?? I found this is important to resample the dpi I seek, then do the image's new dimensions. I would like to rewrite the script as all PerlMagick, perhaps, to see if I can get even better performance.