ImageMagick rotate bug?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Vigour
Posts: 6
Joined: 2011-02-27T03:06:01-07:00
Authentication code: 8675308

ImageMagick rotate bug?

Post by Vigour »

Hi!

I am using ImageMagick on my Mac Mini webserver to rotate images. I just discovered something very strange. If I scan my pictures (tif format) with my Epson scanner and rotate my images everything works ok. But today I took some photos (jpg format) with my Nikon D3000 and tried to rotate them. If I rotate the image left it rotates right. If I rotate left one more time it rotates back (left). So it seems that it rotates left, right, left, right and so on. What is going on here?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick rotate bug?

Post by fmw42 »

Possibly there is some profile or EXIF data that is telling it what orientation it has. You can remove all that info with -strip. See if that helps.

Otherwise, post a link to your image, so others can examine it.

Also please show your exact command line.

Also please identify what version of IM you are using. That is always a good idea when posting. If your IM is very old, then you might upgrade that and possibly libjpg
Vigour
Posts: 6
Joined: 2011-02-27T03:06:01-07:00
Authentication code: 8675308

Re: ImageMagick rotate bug?

Post by Vigour »

I remember that when I took this photo I rotated the camera 90 degrees.

I have tried -strip without any success (not sure if I used -strip in the right way).

The link to my image is:

http://www.thrutherockies.com/DSC_0419.JPG

This is the PHP script that tries to rotate it 90 degrees left.

$exec = "/usr/local/bin/convert '$input' -rotate 270 '$output'";

PHP version is 5.3.3

ImageMagick version is 6.6.5-3

I also discovered that when I use -negate it sets the image to grayscale (that is what I want) but also mirror the image at the same time.

$exec = "/usr/local/bin/convert '$input' -negate '$output'";
Vigour
Posts: 6
Joined: 2011-02-27T03:06:01-07:00
Authentication code: 8675308

Re: ImageMagick rotate bug?

Post by Vigour »

Good news. I used -auto-orient and that seems to fix the problem.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagick rotate bug?

Post by anthony »

Just a warning don't save back to JPG! unless that is your final image. (and keep the original)

JPEG is a lossy file format, and any read and write will degrade the image slightly. The more you read-write the more that file format degrades.

There is a method of non-lossy JPEG rotates (not Image magick) that you can use, but -auto-orient is find if you also plan to use imagemagick to process the image in other ways.

See IM Examples, Photo Handling, for more details...
http://www.imagemagick.org/Usage/photos/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply