use strict; use warnings; use GD; print "GD version : $GD::VERSION\n"; print "libgd version: ",GD::VERSION_STRING,"\n"; my $original_jpg = $ARGV[0]; my $angle = $ARGV[1] ? $ARGV[1] : 90; my $gd = GD::Image->new( $original_jpg ); my $gdrot = new GD::Image($gd->width, $gd->height ); $gdrot->copyRotated( $gd, # source $gd->width/2, # X center of the destination image $gd->height/2, # Y center of the destination image 0, # X specify the upper left corner of a rectangle in the source image 0, # Y specify the upper left corner of a rectangle in the source image $gd->width, # final width $gd->height, # final height $angle # rotation angle clockwise in degrees ); open my $fh,'>', "rotated_".$angle."_".$original_jpg or die $!; binmode $fh; print $fh $gdrot->jpeg;