Page 1 of 1
ImageMagick rotate bug?
Posted: 2011-03-24T04:28:05-07:00
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?
Re: ImageMagick rotate bug?
Posted: 2011-03-24T09:51:22-07:00
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
Re: ImageMagick rotate bug?
Posted: 2011-03-25T05:03:50-07:00
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'";
Re: ImageMagick rotate bug?
Posted: 2011-03-25T06:04:32-07:00
by Vigour
Good news. I used -auto-orient and that seems to fix the problem.
Re: ImageMagick rotate bug?
Posted: 2011-03-25T23:11:35-07:00
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/