Orientation loss after CONVERT

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
mdebraaf
Posts: 5
Joined: 2019-04-08T04:20:05-07:00
Authentication code: 1152

Orientation loss after CONVERT

Post by mdebraaf »

I'm a newbie with Magick but managed to write a script that does the following:

I'm using a freshly installed ImageMagick on my Windows 10 PC (ImageMagick-7.0.8-Q16)

1) Cut out a square image from the centre of an image (JPG)
2) Resize that image into a 400x400 and 800x800 sized image
3) Superimpose a watermarked image (PNG)

Everything works fine (made me very happy) but now I find out that some watermarked images have messed up orientation.
All the resized images (mogrify) have the correct orientation, but as soon as I watermark the pictures with convert, some of them rotate.

For watermarking I use the following code:

for %%F in (*.JPG) do %IM%convert "400x400 WATERMARK Vesper Europe.png" %%F -auto-orient -compose dstover -composite watermarked/%%~nF.jpg

The set of images has been created with an iPhone and a SAMSUNG. I guess that SOME of the iPhone images have lost their proper orientation, however not ALL of them.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Orientation loss after CONVERT

Post by fmw42 »

What is your exact version of 7.0.8x? Try swapping the two input images and change dstover to over.

Code: Select all

for %%F in (*.JPG) do %IM%convert %%F "400x400 WATERMARK Vesper Europe.png" -auto-orient -compose over -composite watermarked/%%~nF.jpg
mdebraaf
Posts: 5
Joined: 2019-04-08T04:20:05-07:00
Authentication code: 1152

Re: Orientation loss after CONVERT

Post by mdebraaf »

Hi fmw42 - thanks for your reaction.

I'm using version 7.0.8-38.

I have tried your proposal (a nifty one) but unfortunately no change in results. The same JPGs change orientation after the last (convert) step.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Orientation loss after CONVERT

Post by snibgo »

mdebraaf wrote:I guess that SOME of the iPhone images have lost their proper orientation, however not ALL of them.
Please link to samples, otherwise we also need to guess.
snibgo's IM pages: im.snibgo.com
mdebraaf
Posts: 5
Joined: 2019-04-08T04:20:05-07:00
Authentication code: 1152

Re: Orientation loss after CONVERT

Post by mdebraaf »

Thanks snibgo,

https://drive.google.com/drive/folders/ ... sp=sharing

The following files are in the folder:

400x400 WATERMARK Vesper Eurpope.PNG - the watermark mask
192013_IMG_0584_400x400_original.JPG - original (resized) image, with mogrify
192013_IMG_0584_400x400_watermarked.JPG - resulting image with watermark
Manipulate images.bat - batch file for processing (resizing & convert) of all JPGs in a folder

Cheers.

P.S. In this case all images tested are from the same iPhone, just taken a few minutes apart. This particular image (IMG_0584) shows this behaviour. E.g. IMG_0585 also in the folder shows correct results
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Orientation loss after CONVERT

Post by fmw42 »

Both these commands work fine for me on IM 7.0.8.39 Q16 Mac OSX. The output contains the EXIF orientation fields.

Code: Select all

magick 192013_IMG_0584_400x400_original.JPG -auto-orient "400x400 WATERMARK Vesper Europe.png" -compose over -composite test.jpg
The preview on the one above is oriented wrong. But the image displays fine in Mac Preview and ImageMagick display.

Code: Select all

magick "400x400 WATERMARK Vesper Europe.png" 192013_IMG_0584_400x400_original.JPG -auto-orient -compose dstover -composite test2.jpg
Note the -auto-orient is after the image, not before it. IM 7 is more particular than IM 6 on syntax.

For this one, the preview is also oriented correctly and the image displays properly also.

Have you tried upgrading to 7.0.8.39? If that still fails, then there is a bug in the Windows version.
mdebraaf
Posts: 5
Joined: 2019-04-08T04:20:05-07:00
Authentication code: 1152

Re: Orientation loss after CONVERT

Post by mdebraaf »

Hi Fred,

thanks for your help & comments. I did upgrade to version IM 7.0.8.39.

This (alone) was not the culprit....

I tried the codes you provided inside my batch file and "magick" happened .... it worked.
However, the preview in Windows Explorer is still wrong, as you also mentioned. But opening with my favourite image viewer (ifanview), it showed OK.

I'm not sure how those previews are generated ..... something for other folks to find out I guess.

I do not understand the difference between the CONVERT and MAGICK command. I guess I need to do a lot of reading.

I'm happy I managed - with help - my first Magick project. Appreciate the time you took.

cheers, Michael
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Orientation loss after CONVERT

Post by fmw42 »

convert is for IM 6. magick is the same but for IM 7. The name was changes to avoid confusion and due to changes in IM 7, also to avoid conflict with Windows convert.

See https://imagemagick.org/script/porting.php#cli
mdebraaf
Posts: 5
Joined: 2019-04-08T04:20:05-07:00
Authentication code: 1152

Re: Orientation loss after CONVERT

Post by mdebraaf »

Hi Fred,
thanks ! Clear. The conflict within Windows was already experienced ;-)
Post Reply