ImageMagick to rotate an image

J

Jason C

I understand that I can use convert() in ImageMagick to rotate an uploaded picture. The question, though, is how to automatically determine when the picture NEEDS to be rotated?

I know that I can set up a button for the user to manually click if they want to rotate the picture, but is there a way to do it without asking? I've seen it done on bigger sites, but I don't know if it's a simple command that already exists, or if it's a big system that they've bought.
 
P

Peter J. Holzer

Quoth Jason C said:
I understand that I can use convert() in ImageMagick to rotate an
uploaded picture. The question, though, is how to automatically
determine when the picture NEEDS to be rotated?
[...]
I believe this is usually done by reading the EXIF data, assuming the
camera put any there. (Why the camera does this rather than simply
rotating the picture I don't know.) This is not something I know much
about, but Image::ExifTool looks like a... rather complete
implementation. Probably you want the 'Orientation' tag;

Rotation or Orientation, yes. Apparently both are in use.

Here is what I use:

use Image::ExifTool qw(ImageInfo);
...
my $info = ImageInfo($filename);
my $rot = $info->{'Rotation'} || $info->{'Orientation'};
my ($angle) = $rot =~ m/Rotate (\d+) CW/;
return $angle;

hp
 
J

Jason C

Rotation or Orientation, yes. Apparently both are in use.



Here is what I use:



use Image::ExifTool qw(ImageInfo);

...

my $info = ImageInfo($filename);

my $rot = $info->{'Rotation'} || $info->{'Orientation'};

my ($angle) = $rot =~ m/Rotate (\d+) CW/;

return $angle;



hp

Thanks, guys (both Peter and Ben). I think this will help a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top