follow orientation issue

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Post Reply
mastabog
Posts: 6
Joined: Wed Nov 26, 2008 7:03 pm

follow orientation issue

Post by mastabog »

Hi,

I have a series of photos that are all landscape 2592x1944 but some have a 90 degrees orientation flag. I would like to use Nconvert to resize *and* rotate them with the following constraints:

- keep aspect ratio
- *either* width or height be 1024 pixels
- have them rotated following the EXIF orientation flag, meaning that I'd like the end image to be 768x1024 for those that had a 90/270 degrees orientation and 1024x768 for those with 0/180 degrees orientation.

I have tried all sorts of options for nconvert. It always resizes to 1024x768. It does not rotate the photos with a 90 degrees orientation. Among the options I've tried are:

-resize 1024 1024 -ratio -rflag orient
-resize 1024 768 -rflag orient
-resize 1024 0 -ratio -rflag orient

It seems that the rflag orient is ignored ... or maybe I'm missing something, i understand it should switch the W/H and turn the end image into a 768x1024 but it does not.

Any ideas?

p.s. i can do it with imagemagick's convert by using -auto-orient but I wanted to use Nconvert from xnview
User avatar
xnview
Author of XnView
Posts: 43598
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: follow orientation issue

Post by xnview »

Use

Code: Select all

 -ratio -rflag orient -resize 1024 1024
Pierre.
mastabog
Posts: 6
Joined: Wed Nov 26, 2008 7:03 pm

Re: follow orientation issue

Post by mastabog »

xnview wrote:Use

Code: Select all

 -ratio -rflag orient -resize 1024 1024
Does the ordering of the command line parameters matter?
If not then I already tried it, see my message above:
mastabog wrote:Among the options I've tried are:

-resize 1024 1024 -ratio -rflag orient
User avatar
xnview
Author of XnView
Posts: 43598
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: follow orientation issue

Post by xnview »

mastabog wrote:
xnview wrote:Use

Code: Select all

 -ratio -rflag orient -resize 1024 1024
Does the ordering of the command line parameters matter?
Yes for -resize
Pierre.
szucsati
Posts: 1
Joined: Sun Oct 24, 2010 4:22 pm

Re: follow orientation issue

Post by szucsati »

Hi,

I have a similar problem. My photos are landscape, portrait, or wide. I'd like to resize them in batch.
Let's say these dimensions:
Landscape: 1280 x 960, 1024 x 768, 800 x 600 = resize to = > 320 x 240
Portrait: 960 x 1280 = resize to = > 240 x 320
Wide: 1280 x 720 = resize to = > 320 x 180

If I use batch processing in XnView and select "Keep ratio" & "Follow orientation" it works perfectly. But can't get NConvert to do it, no matter what the parameter order is. Here's my batch file:

Code: Select all

nconvert -out jpeg -opthuff -subsampling 2 -dct 2 -q 98 -rtype lanczos -ratio -rflag orient -resize 1824 1368  -keep_icc -clean 1 -clean 4 -clean 16  -overwrite -quiet *.tif 
This makes portrait photos 240 x 180 instead of 320 x 240.

What am I doing wrong?

Attila
User avatar
xnview
Author of XnView
Posts: 43598
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: follow orientation issue

Post by xnview »

Pierre.
u0206397
Posts: 3
Joined: Sat Apr 21, 2012 2:16 pm

Re: follow orientation issue

Post by u0206397 »

Hi this might have come a little late but I found something while facing and researching the same problem i.e. the output images were not auto-oriented or rotated while the input images though not oriented correctly as image files have the correct EXIF data embedded inside. The workaround that works for me requires 2 steps: step 1 rotates the source image, followed by step 2 which does the resizing based on the existing orientation (landscape/portrait).

Step 1:

Code: Select all

nconvert -jpegtrans exif -out jpeg -o output.jpg input.jpg
The -jpegtrans exif seems to be applied silently or implicitly when the batch processing is done via the XnView or XnConvert GUI, but not so in NConvert command line.

While running, for those input images that need to be oriented or rotated, NConvert will report:

Code: Select all

Lossless transformation of input.jpg : OK
This may alarm the user as if the original input image is being rotated and modified but I have checked and the input image remains unchanged, while the intermediate output file is rotated correctly. Seems to me the transformation took place in memory and get written out correctly, while leaving the original input image file intact. Just my observation so far but I might be wrong, so try this out yourself using a copy and don't blame me if you get your input files overwritten!

Step 2:

Code: Select all

nconvert -ratio -rflag orient -resize 640 480 -overwrite output.jpg
Note: The output.jpg from step 1 is an intermediate working copy that is eventually overwritten by the resized version of itself.

Hope this helps or provide some clue to others with the same problem. Btw, I experimented with combining both the JPEG transformation and resizing in one command by specifying all the switches but failed. NConvert seems to happily transform but ignore the resizing, so I had to keep them separated into 2 commands for now.
Post Reply