Skip to content

Commit 841e959

Browse files
committed
new file: Image/image-hard-rotate.pl
1 parent 4534977 commit 841e959

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Image/image-hard-rotate.pl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/perl
2+
3+
# Author: Trizen
4+
# Date: 10 August 2025
5+
# https://github.com/trizen
6+
7+
# Hard-rotate images that contain the "Orientation" EXIF tag specified as "Rotate 90 CW" or "Rotate 270 CW".
8+
9+
use 5.036;
10+
use Imager;
11+
use Image::ExifTool qw(ImageInfo);
12+
13+
foreach my $file (@ARGV) {
14+
15+
say ":: Processing: $file";
16+
17+
my $info = ImageInfo($file);
18+
my $orientation = $info->{Orientation};
19+
20+
if (defined($orientation) and $orientation =~ /^Rotate (\d+) CW/) {
21+
22+
my $angle = $1;
23+
say "-> Rotating image by $angle degrees clockwise...";
24+
25+
my $img = Imager->new(file => $file) or die Imager->errstr();
26+
$img = $img->rotate(degrees => $angle);
27+
unlink($file);
28+
$img->write(file => $file) or die $img->errstr;
29+
}
30+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ A nice collection of day-to-day Perl scripts.
539539
* [Gd star trails](./Image/gd_star_trails.pl)
540540
* [Gif2webp](./Image/gif2webp.pl)
541541
* [Horizontal scrambler](./Image/horizontal_scrambler.pl)
542+
* [Image-hard-rotate](./Image/image-hard-rotate.pl)
542543
* [Image-unpack](./Image/image-unpack.pl)
543544
* [Image2ascii](./Image/image2ascii.pl)
544545
* [Image2audio](./Image/image2audio.pl)

0 commit comments

Comments
 (0)