Page 1 of 1

how do I rotate image and strip meta using convert?

Posted: 2019-01-03T12:39:05-07:00
by newbie_user
I am using convert to create a new image, rotate and striping meta info but it fails to rotate when using -strip. I assume because strip removed the EXIF:orientation. So


magick convert "IMG_20180830_110737.jpg" -rotate 180 -strip "new_IMG_20180830_110737-4.jpg" results in image not being rotated and removing -strip results in rotated image with meta info.

how do I accomplish both?
using Version: ImageMagick 7.0.7-31 Q16 x64 2018-05-07

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-03T15:43:11-07:00
by fmw42
There is no reason that -rotate 180 would not work. You already have -strip after it, which is proper. However, your viewer may be seeing the EXIF orientation and automatically correcting it. But then your rotate and strip and get back to the original orientation.

If the EXIF data has orientation information, then just use -auto-orient.

For IM 7, use magick, not magick convert and not convert.

Code: Select all

magick "IMG_20180830_110737.jpg" -auto-orient -strip "new_IMG_20180830_110737-4.jpg"

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-03T21:23:56-07:00
by Mom4321
You could use the auto-orient option of convert to do this. Also Don't forget you can use mogrify instead of convert if you want to replace the existing file (in-place), which is useful when you want to do a directory full.

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-03T23:50:50-07:00
by newbie_user
fmw42 wrote: 2019-01-03T15:43:11-07:00 There is no reason that -rotate 180 would not work. You already have -strip after it, which is proper. However, your viewer may be seeing the EXIF orientation and automatically correcting it. But then your rotate and strip and get back to the original orientation.

If the EXIF data has orientation information, then just use -auto-orient.

For IM 7, use magick, not magick convert and not convert.

Code: Select all

magick "IMG_20180830_110737.jpg" -auto-orient -strip "new_IMG_20180830_110737-4.jpg"
So I tried your code and it doesn't rotate, image still upside down. Tried this and didn't work either.

Code: Select all

magick "IMG_20180830_110737.jpg" -rotate 180 -strip "new_IMG_20180830_110737-4.jpg"
remove -strip and -rotate works, -auto-orient still doesn't. Using irfanviewer 4.51 and windows thumbnails show it upside down as well.

Odd thing is on SOME when I used only -strip the image rotated automagically but only on some. Go figure!

If I use windows explorer to rotate the image, I notice EXIF orientation is added, I then use -strip and image is upside down again.
If I use irfanviewer to rotate no exif data is added and image stays rotated.

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-03T23:52:23-07:00
by newbie_user
Mom4321 wrote: 2019-01-03T21:23:56-07:00 You could use the auto-orient option of convert to do this. Also Don't forget you can use mogrify instead of convert if you want to replace the existing file (in-place), which is useful when you want to do a directory full.
mogrify isn't and option as I have to keep the original files unmodified and I cant get -auto-orient to work at all. I'm open to other ideas thou.

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-04T00:07:25-07:00
by fmw42
Post one of your images that seems to have issues. Perhaps there is no EXIF orientation in the file.

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-04T11:09:25-07:00
by newbie_user
both images are orientated with EXIF:Bottom Right and taken with same camera.
irfran and windows (thumbnail) show same orientation (on originals) and varies on modified


strip flips correctly but rotate strip does not -
Image 1 - Originally orients upside down on my PC
https://imagebin.ca/v/4SNDUUUchVf3
strips and flips

Code: Select all

magick image1.jpg -strip newimage1-1.jpg

strips and no flip

Code: Select all

magick image1.jpg -rotate 180 -strip newimage1-2.jpg

does not work (does do something to Image 2)

Code: Select all

magick image1.jpg -auto-orient newimage1-3.jpg



Already orientated correctly so strip should just remove the EXIF but -strip flips the image upside down.
Image 2 - Original orients correctly on my PC
https://imagebin.ca/v/4SNEsfAU7cve

strips and flips (wrong)

Code: Select all

magick image2.jpg -strip newimage2-1.jpg

strips and flips

Code: Select all

magick image2.jpg -rotate 180 -strip newimage2-2.jpg

works (windows thumbnail is upside down, exif shows top left now)

Code: Select all

magick image2.jpg -auto-orient newimage2-3.jpg


Thanks for the help, very appreciated

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-04T11:23:02-07:00
by fmw42
Both these work fine for me on IM 7.0.8.23 Q16 Mac OSX

Code: Select all

magick image.jpg -auto-orient image2.jpg

Code: Select all

magick image.jpg -auto-orient -strip image3.jpg
Thumbnails look correct on my Mac.

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-04T11:43:45-07:00
by newbie_user
I installed Version: ImageMagick 7.0.8-23 Q16 x64 2019-01-02 (dll) on clean windows 10 pro and still does not work.
I downloaded image1 and image2 from above and noticed imagebin has image 1 right side up and image 2 upside down.
This is opposite to what PC shows. Verified the both downloaded images are still set to bottom right as well.

Re: how do I rotate image and strip meta using convert?

Posted: 2019-01-04T12:28:10-07:00
by fmw42
Yes, for me your first image does not work properly with -auto-orient. But the second image does work fine for me on IM 7.0.8.23 Q16 Mac OSX. I do verify that both images have EXIF:orientation of 3.

I am not sure what is wrong. A guess would be something odd in your file.