Announcement

Collapse
No announcement yet.

Resize image with non default orientation flag

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Resize image with non default orientation flag

    Resize image with non default orientation flag

    Hi
    Suppose original image has an orientation of 6 right-top (but actually anything not default), for both image and embedded thumbnail.
    I want to resize the image, in order to get an image with the same 6 right-top orientation (image and thumbnail) OR the corresponding 1 top-left oriented (image and thumbnail), correctly rotated.

    I tried Resize with Reset Orientation Flag, then did a lossless Rotation (Transformation None with Rebuild thumbnail) and got the correct 1 top-left (image and thumbnail) oriented image.
    I guess a lossless Auto Rotate and then a resize would also get the correct 1 top-left (image and thumbnail) oriented image.

    Now the questions.
    1. Is it correct the fact that Resize with Reset Orientation Flag results in Image Orientation and Thumbnail Orientation flags out-of sync? Image and thumbnail are displayed correctly, even if flags not match.

    2. Is it possible to obtain the same image resized, either the 6 right-top orientation (image and embedded thumbnail) OR the corresponding 1 top-left oriented (image and embedded thumbnail), correctly rotated, but all in a single step (fewer operations)?

    3. Finally, I am looking for a way to do this resize and eventually compensating actions (to correct orientation) in a batch, so suggestions are welcome to do it as simple as possible.
    Last edited by FeriM; 30.11.2017, 12:57 AM.

    #2
    This is a bit complicated and confuses a lot of users. Note that what I say below only applies to Jpeg files - I assume that is what you are using.

    Yes. Reset Orientation flag will always set the EXIF orientation tag to 1, Top Left. It will then stay at 1 whatever you do with it in Irfanview. There is no option I know of in Irfanview to change it back to any other value. You need a different program if you want to do that.
    Lossless auto rotate uses the existing flag to rotate the image to the correct orientation and then sets the flag to 1 whether you ask for it or not.
    Lossless resize will leave the tag alone unless you ask to reset it.

    If you use the normal Left or Right rotations (non lossless) then you still have the option available to reset the tag to 1 when you save it should you want to. Do think carefully about whether you want to do that before you set it though.

    Note that the image you save is WYSIWYG. The image will be saved the same way up as you see it on screen even though it may have been rotated there automatically if you have checked "Auto rotate image according to Exif info.." in the JPG/PCD/GIF tab of the Properties dialog. I have actually used this odd behaviour as a way of correcting for an incorrect Exif tag. You cannot change the Exif tag, as I said earlier, but you can change the image. With Auto rotate turned on (before you open the image) just use left or Right rotations to display the image right way up, then Save with "Reset Orientation tag ..." turned off in the Jpeg Save options dialog. That will leave the tag set as it was and, if you view it again with Auto rotate on, it will appear the correct way up. It may look a bit odd without Auto rotatation though.
    Last edited by Mij; 30.11.2017, 08:28 PM.

    Comment


      #3
      Thanks for the effort to respond.
      You are right, I am referring to Jpeg. Also, I use IV with "Auto rotate image according to Exif info.." checked.
      Other than that, I am not sure which of my questions you tried to answer... and what the answer is.
      Whoever reads my questions, please let me know if there are not clear enough and I will try to make them more clear.
      Actually, let me just try that:
      1. I find it weird for the Image Orientation and Thumbnail Orientation flags to be out-of-sync after the resize that i mentioned. Resulting image has Orientation 1, thumbnail has orientation 6 (original). Some people may call that a bug, even if the image and thumbnail are displayed correctly.
      2. I found out I need to do at least two operations: a lossless Auto Rotate and then the resize to get an 1-1. What would be the most simple way to get a correctly oriented image after resize, and keeping the Image and Thumbnail Orientation flags in sync (1-1 or 6-6)?
      3. Asking about the most simple way to do this in a batch.
      Thanks

      Comment


        #4
        Before I reply I always try to judge from the question how familiar the writer is with Irfanview. I sometimes get it wrong, but do please remember that I am not just replying for your benefit. Already, just 2 days after your post, there have been 67 views of this thread and that number will continue to increase for some time to come.

        So first of all a comment on Jpeg Lossless rotation. This is a good way to Resave an image if you just want to correctly rotate and set the Exif rotation tag back to the default setting of Top Left, because it is (a) lossless and (b) simple to do (all the hard work is done for you).
        If you want to do it to a lot of image files you cannot use the File >Batch Conversion/Rename feature but you can do the contents of (up to) a complete folder at a time by using File >JPG lossless Operations in the Thumbnail viewer.
        You can also handle multiple images using the Command Line interface or by writing Batch or other script files. Head for the Command Line and Scripts section of the forum if you want to ask about that.

        If you want to edit the image (including resizing) at the same time as the rotation then you cannot use a lossless method. You can do it using a non-lossless method but, as I said earlier, it is confusing, as I am sure you will see from my illustrated description below of how to do the equivalent of the jpeg lossless rotate. It makes use of the "Auto rotate image according to Exif info.." option that you will find in Irfanview settings in the JPG/PCD/GIF dialog box.
        I am using for illustration an image which has orientation 6. It is in a folder that also has images with orientation 1,3 and 8 too as you will see. We will start with Auto rotate unchecked in Irfanview because I want to point out some potential pitfalls.

        Image 1 below is with "Auto rotate.." unchecked (Off). It shows 3 windows, a "Windows File Explorer" thumbnail view, an Irfanview Browser view and an Irfanview Thumbnail view. You will see that File Explorer always has its Auto rotate On so that all 4 thumbnails are correctly rotated there but in Irfanview Browser and Thumbnails the original images are shown unrotated because Auto rotate is Off.

        In Image 2 I have turned the Irfanview "Auto rotate.." option On but I have also had to reload the images. That is because the Auto rotate is applied to images in both the Browser and Thumbnails windows when they are opened. There is no automatic re-opening of the images when you make a change to the Auto rotate setting. There are several ways to force a reload of the Browser window. You can use File >Reopen (or press Shift+R) or you can Jump to Next image then Back again, but neither will reload the Thumbnails. If you want to update both Thumbnails and Browser then the quickest way is to select a new folder in Thumbnails then back to the original one. That will leave the Browser window blank so double click on the thumbnail of the image you want and that will reload it in the Browser window too. Now both on the Browser and Thumbnail windows the image are shown correctly rotated. If you want to resize or do any other edit then you would do it now.

        In image 3 the image is about to be saved as a Jpeg (I am actually doing a Save As to a different filename because I want to keep my original, but Save with the original name if you want to). Note that I have the Jpeg Save options dialog showing and "Reset Orientation.." box is Checked.

        In image 4 you see the results of the Save. Again there is no automatic reload but as the Save operation is WYSIWYG both Browser and Thumbnail views should be unchanged from what you saw in image 2.

        For completeness I have shown in image 5 what you would see if you turned "Auto rotate.." Off again and reloaded both Windows.
        In practice you can just leave the setting On all the time and never need to see either image 1 or 5. You then do not need to keep changing the Option nor messing about with reloading the windows. You should be able to use Batch conversion/rename and all you need to set up is the Resize or other Edit you may want. All the rotating to orientation 1 will be done automatically for you when you save the file... but if you want to keep orientation 6 you will need to set "Auto rotate.." to Off and either do your editing with the image rotated or keep switching between "Auto rotate.." On and Off ... and the best of luck.

        Click image for larger version

Name:	1 Original Auto rotate off.png
Views:	1
Size:	223.8 KB
ID:	82986 Click image for larger version

Name:	2 Original Auto Rotate on.png
Views:	1
Size:	241.4 KB
ID:	82987 Click image for larger version

Name:	3 Saving.png
Views:	1
Size:	313.3 KB
ID:	82988 Click image for larger version

Name:	4 Result Auto rotate still on.png
Views:	1
Size:	281.3 KB
ID:	82989 Click image for larger version

Name:	5 Result Auto rotate now off.png
Views:	1
Size:	285.2 KB
ID:	82990
        Last edited by Mij; 03.12.2017, 05:33 PM.

        Comment


          #5
          Thanks again for posting.
          I'll try to draw some conclusions then...
          1. I still find it weird to get a Jpeg having the Image Orientation and Thumbnail Orientation flags out-of-sync, no matter what the operation(s) that lead to that was/were.
          2. When "Auto rotate.." option is set, for images having an orientation flag set, before doing any operation (resize or whatever, maybe a rotate if the camera sensor didn't get the correct orientation), it is recommended to do a lossless Auto Rotate first (to get the top-left oriented flags for image and thumbnail, but keep the view indicated by the sensor), and then proceed with the desired operation (resize etc).
          One could try to do operations with "Auto rotate.." unchecked, but I think this may be confusing and error prone to many people (easier for a resize, harder for rotations).
          3. Since there is a two step thing to do an operation on a file, I guess for multiple files it would require to do the same steps, by selecting multiple files and using the context menu in the thumbnail view.
          Anyone with a quicker solution just let me know.
          Last edited by FeriM; 03.12.2017, 10:19 PM.

          Comment


            #6
            OK. I have left it a couple of days and nobody else has attempted to comment, so I have attempted to.

            1. Before I produced those attachments in post #4 I added "$E274" to the Status bar text in the Viewing tab of the Irfanview settings so that I could show the orientation tag of the Image (bottom right of the Browser window). I have no idea how you know what the orientation tag of the Thumbnail is or even where the thumbnail that you are using to compare the orientation is. You said in your first post that the Image and Thumbnail are displayed correctly. So what exactly is it that you find "weird"?

            2. I am not recommending that you do a lossless Auto rotate if you want to follow it with a resize operation. It will no longer be lossless when you save it again, it is not necessary and it will not rectify images that have an incorrect rotation tag. With "Auto-rotate.." checked in the Viewing tab of the Settings and "Reset orientation tag.." checked in the Jpeg Save options, Irfanview will do exactly the same as lossless Auto-rotate does just simply by saving the image again after it has been Resized or otherwise edited. If the initial orientation tag is correct you end up with an image that is rotated correctly with the orientation tag set to the default (top left), exactly the same as in the Lossless auto-rotate function. The default orientation tag does nothing to the image so it is the same as having no tag at all. Confusion only starts if the initial tag is incorrect or you decide that you want to retain some or all of the orientation tags after the resize. Getting rid of Exif tags is easy, keeping them is a lot harder.

            3. So you can use Batch Conversion/Rename to resize and save a large number of images and the rotation of the image is intrinsic to the process. Here is a brief step by step set of actions.
            (a) Open Irfanview and go to Options>Properties/Settings (or press hotkey "P"). Open JPG/PCD/GIF tag and make sure "Auto-rotate image..." is checked. Press OK.
            (b) Open File> Batch Conversion/Rename (hotkey "B"). In the Dialog click "Batch conversion" button and set Output format to "Jpg-..". Click the Options button to the right and make sure that "Reset EXIF Orientation tag ..." is checked. Press OK.
            (c) Check "Use Advanced options.." and click "Advanced" button to the right. In that dialog set the editing you want done. In my set up I have checked "Resize", "Set one or both sides to..", "Width" 600, "Height" 600 and "Pixels", "Preserve aspect ratio..", "Use resample function.." (optional), and under MISCELLANEOUS "Overwrite existing files" (if you are sure you want to do that) or "Create subfolders in destination folder" (if you are not), then "OK"
            (d) In "Output directory for result files.." type "$D" (if you are sure you want to overwrite existing files) or "$D-Copy" (if you are not)
            (e) Now all you need to do is open the folders with files you want to convert in the "Look In.." box, and Click "Add all" (if you want them all) or make a selection and Click "Add".
            (f) Then click "Start Batch" and let it get on with it.

            Thought you might like these images to play with ;
            Click image for larger version

Name:	XO1.jpg
Views:	4
Size:	19.4 KB
ID:	82994 Click image for larger version

Name:	XO3.jpg
Views:	4
Size:	25.5 KB
ID:	82995 Click image for larger version

Name:	XO6 with wrong tag.jpg
Views:	1
Size:	30.6 KB
ID:	82996 Click image for larger version

Name:	XO6.jpg
Views:	4
Size:	25.9 KB
ID:	82997 Click image for larger version

Name:	XO8.jpg
Views:	4
Size:	26.4 KB
ID:	82998
            Last edited by Mij; 05.12.2017, 08:52 PM. Reason: Added images I use to try out orientation tags

            Comment


              #7
              Well, since you put so much effort in it, I'll answer your questions.

              1.
              "I have no idea how you know what the orientation tag of the Thumbnail is"
              I used another viewer, XnView to examine the metadata. It displays Exif data and ExifTool results. I guess IV can show it also. The flag values for Image Orientation and Thumbnail Orientation were different and mismatching after resize.

              "where the thumbnail that you are using to compare the orientation is"
              The IV Thumbnails displays embedded thumbnail from the Jpg, if you didn't set another option.

              "You said in your first post that the Image and Thumbnail are displayed correctly. So what exactly is it that you find "weird".
              I find it weird that you start with the same values for those flags, do a resize, and then the flag values do not match. Visually all is fine.

              2.
              To my knowledge, resize is not lossless (you loose information). Lossless rotation is lossless. So you can do any number of lossless rotations before or after a resize, quality related it would be the same as one resize. I was trying to get a result with some "order" in metadata also (avoid the Orientation flags issue), with minimal effort.

              3.
              What you describe is pretty much my first attempt, for multiple files. There is nothing wrong with it except the Orientation flags mismatch I described. It may be fine for most people.

              Thanks for your interest.

              Comment

              Working...
              X