Announcement

Collapse
No announcement yet.

JPG lossless rotation

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

    JPG lossless rotation

    Questions about JPG lossless rotation:

    1. When I do batch JPG lossless auto rotation, IV modifies all files, even those which don't need to be rotated (EXIF orientation flag "top left"), and even if "optimize" and "set DPI" are unchecked, and "keep all markers" is checked. What does IV do to the files that don't need to be rotated, and why?

    I like batch lossless auto rotation, but would rather not touch files that don't need to be touched, even if modification is lossless. Is there a way to have IV go through a bunch of JPGs, losslessly auto rotate those that need to be rotated, and skip the ones that don't? If not, is there another program that can do this?

    2. IV help says JPG rotation is fully lossless only if image height is multiple of 16 pixels, and the remainder pixels are discarded. Does "height" refer to the longer dimension or something else? My Canon A610 5MP camera produces 2592x1944 JPGs, and the shorter dimension 1944 is not divisible by 16. I tried IV lossless rotation on these, and didn't see anything like 8 pixels being cropped on the shorter side. But I would like to confirm that the rotation is fully lossless despite the shorter dimension not divisible by 16.

    Thanks

    #2
    Hi pupkin,

    1. You are right, IrfanView modifies even files which don't need to be rotated. I don't know why (this is a question for Irfan). But when they are re-saved, I presume they are once again JPEG compressed. Oddly, when I made a test with a 1.87 MB file, I obtained a new file 35 bytes bigger than the original.

    2. With your test, I believe you answered the question by yourself. It seems that a picture with a height of 1944 pixels is not cropped if it is not rotated.

    Laurent
    Before you post ... fill in your OS and IV version in your profile.

    Comment


      #3
      Thanks, Laurent

      Does anybody have suggestions on how to do selective batch lossless auto rotation, where only files that need to be rotated are processed? If not with IV, perhaps with another program? For example, can "JPEG Lossless Rotator" do that?

      Now, I found an easy way to confirm that a JPG rotation is truly lossless: rotate, then rotate again to the original orientation (if the first operation actually rotated), save original and new JPG to BMP, binary-compare BMPs (for example using "compare by content" in Total Commander). Thus, I was able to confirm that the following are truly lossless in IV:

      a) Batch JPG lossless auto rotation, both for JPGs that need to be rotated and those that don't. IV modifies all files, but for those that don't need to be rotated it probably just rewrites headers/markers (if "optimize" is unchecked) in a slightly different way (still don't know why) resulting in a slightly different file size. No recompression.

      b) JPG lossless rotation for 2592x1944 files, even though 1944 is not divisible by 16. No crop or other modification here. Still don't know what "height" refers to when IV help says that height must be multiple of 16, but it looks like lossless rotation works fine when the long side is divisible by 16 and the short side is divisible by 8.

      One can easily do the same test for additional scenarios, like when "optimize" is checked, when both sides are divisible by 8 but not 16, etc.

      Comment


        #4
        Confirmed that Automatic option in JPEG Lossless Rotator does what I want: look through all JPGs in a folder, keep those that can't be autorotated (EXIF orientation tag = "top left") untouched, and losslessly auto rotate, reset EXIF orientation tag and keep other EXIF tags etc for those that can be autorotated. (JPEG Lossless Rotator gives false warnings that rotation is not fully lossless when using manual rotation for 1944x2592 JPGs, but this doesn't affect automatic rotation.)

        If anyone knows how to do this with IV, please share.

        Comment


          #5
          If you have not yet rotated any of the images then it is usually quite easy to do.

          1. Make sure that Auto-rotate image according to EXIF image is checked in Options> Properties> JPG/PCD/GIF
          2. Open the folder in Thumbnails. The images that need to be rotated 90 or 270 degrees will be displayed in Portrait format
          3. In thumbnails menu set Options> Sort by> Portrait/Landscape.
          4. Select the block of Portrait images.
          5. Right click on the block and select JPG lossless Operations> Lossless rotation with selected files> Auto rotate> Start

          Two possible snags
          a) if you have any images already rotated to portrait then these will also be selected in 3
          b) images requiring 180 degree rotation will not be selected

          The alternative is to sort using (Vista) Windows Explorer. From the Explorer menu you can select View> Sort by> More> Orientation. Probably best to display in Details view. Click on the orientation column header to group into Normal, Rotate by 90 deg, Rotate by 180 deg, and Rotate by 270 deg.

          6. Open IrfanView at the Slideshow dialog. Remove All from the list pane and drag those images that need to be rotated from Windows explorer into that pane. You can do this for any number of folders. You will see that the full path and file names have been listed.
          7. Save the list using Save filenames as TXT file
          8. Close slideshow dialog. Open Thumbnails.
          9. Select Options> Load file list from TXT file
          10. Select all (Ctrl+A) and do lossless rotate as in 5.

          It is clearly more laborious but it does get around snags a) and b) and enables you to work with more than one folder at a time.

          If only the Batch dialog offered Jpeg lossless operations you could get there much quicker and without having to save an intermediate TXT file. One day perhaps.....

          Comment


            #6
            Thanks, Mij! That's what I was talking about. The issues a) and b) are not really issues for me. If IV redoes some files that have already been rotated, not a big deal as those are not "original" anyway. And I never have images that need to be rotated 180 degrees. (Why would anybody shoot upside down?)

            Going the Explorer way, I guess one can create a temp subfolder, drag/move all files with Orientation other than Normal there, do batch lossless auto rotation from IV Thumbnails, then move the files back and delete the subfolder. May be a bit simpler than dealing with TXT, although would need to do one folder at a time or figure out which files to move back to which folder.

            That said, I really like JPEG Lossless Rotator. It adds a context menu item, so I don't even need to open any programs - just right-click on the folder in Windows Explorer or Total Commander and select "Automatically Rotate JPEG Images". It has its own issues - in addition to the false warnings in manual mode that I mentioned before, it doesn't work well with read-only files (keeps asking to confirm for each file and changes file dates despite "Keep File Timestamp" selected in Options). But it is easier than using IV, even if I need to clear "Read-only" in folder Properties before clicking "Automatically Rotate..."
            Last edited by pupkin; 08.10.2009, 04:10 PM.

            Comment


              #7
              Originally posted by pupkin View Post
              IV help says JPG rotation is fully lossless only if image height is multiple of 16 pixels, and the remainder pixels are discarded. Does "height" refer to the longer dimension or something else? My Canon A610 5MP camera produces 2592x1944 JPGs, and the shorter dimension 1944 is not divisible by 16. I tried IV lossless rotation on these, and didn't see anything like 8 pixels being cropped on the shorter side. But I would like to confirm that the rotation is fully lossless despite the shorter dimension not divisible by 16.
              I believe the 16 pixels is a general warning for JPG images, but not a strict rule. It really depends on the dimensions and the type of color subsampling, what the limitations are. Some can be rotated over and over without loss, some only once or a few times, others not at all. The height refers to the second dimension, since dimension is expressed as width x height.

              For some insight on this tricky subject, you should start with these links and read their related articles:

              JPEG Lossless Rotation, Lossless Crop
              Digicams and Lossless Rotation

              Comment

              Working...
              X