#!/usr/bin/perl -l use strict; use Image::Info; my %o = ( top_left => 0, right_top => 90, left_bot => 270 ); opendir DR,"."; foreach (grep !/^\.{1,2}$/,readdir(DR)) { my $angle = $o{%{Image::Info::image_info($_)}->{Orientation}}; if ($angle) { print $_." action $angle rotate"; rename($_,$_.".old"); system "/usr/bin/jpegtran-mmx -rotate $angle -trim -copy all -outfile $_ $_".".old"; } else { print $_." no action" } } closedir DR; exit 0