Page 1 of 2
Lossless rotate question
Posted: Wed Sep 22, 2010 6:25 am
by drugo
can i ask a question about Lossless rotate ?
does xnview store the rotate change in the exif only?
is this the meaning of Lossless rotate ?
thanks
Re: Lossless rotate question
Posted: Wed Sep 22, 2010 7:49 am
by xnview
In Options/Browser>Misc, you can choose if you want to change only the EXIF flag or make a lossless rotation
Re: Lossless rotate question
Posted: Wed Sep 22, 2010 1:46 pm
by Karl02
The current options look like this (v1.97.8):
Code: Select all
[ ] Change EXIF orientation ONLY when possible (JPEG)
[ ] Use Lossless rotation when possible (JPEG)
This is unclear and misleading, because the change of the EXIF orientation tag is a special case of a lossless rotation and not independent. Therefore, the options should be displayed as follows:
Code: Select all
[ ] Use lossless rotation if possible (JPEG)
[ ] Only change the EXIF orientation tag
If the lossless rotation is unchecked, the EXIF rotation option should be deactivated.
See also my post here from two and a half years ago:
http://newsgroup.xnview.com/viewtopic.p ... 265#p58265
Re: Lossless rotate question
Posted: Wed Sep 22, 2010 2:54 pm
by xnview
No it's a different choice. You have lossless rotation (which change picture data), and EXIF orientation field
Re: Lossless rotate question
Posted: Wed Sep 22, 2010 4:35 pm
by Karl02
The current display of the options is misleading. You cannot use them independently.
Re: Lossless rotate question
Posted: Wed Sep 22, 2010 4:45 pm
by drugo
xnview wrote:No it's a different choice. You have lossless rotation (which change picture data), and EXIF orientation field
but what 's the meaning of lossless ? is the meaning a little loss of image quality?
Re: Lossless rotate question
Posted: Thu Sep 23, 2010 12:44 pm
by JohnFredC
Hi drugo...
Lossless rotation applies only to jpgs and other formats that use a "lossy" compression algorithm.
In order to reduce file size when saving the image to disk, the jpeg engine compresses the image data in a "lossy" manner... this means that the engine discards image information (either pixel position or color or both) in order to make the saved image file smaller. Conversely, when expanding the image out of the file to the display, the jpeg engine "estimates" the lost data and attempts to restore the image to as close to the original (in appearance) as it can. Naturally, since image data has been discarded, the original cannot never be completely restored.
The important thing to remember is that every time one loads a jpg and then saves it, more data is discarded. Eventually the loss of original image data becomes quite noticeable to the eye.
"Lossless rotation" attempts to avoid the loss of quality that happens when the file is saved (after the rotation has been applied). Lossless rotation takes into account mathematical characteristics of the jpeg compression to allow image rotation to occur "in place" (that is, without recompression) for images whose horizontal and vertical dimensions meet certain criteria.
So... use lossless rotation on jpgs.
I always recommend that one convert images from jpg to a lossless compression format (tiff, or png, or psd) before starting the editing/adjustment process. When the images have been rotated, corrected, or otherwise modified to the extent required, then (and only then) should the user convert them back to jpg for distribution as smaller files. (Lossless compression tends to make much large files than lossy compression does).
This topic has been discussed several times previously in the forum. It is actually more complicated than presented here, but you get the idea.
Re: Lossless rotate question
Posted: Thu Sep 23, 2010 1:29 pm
by Karl02
Lossless means no loss of image quality.
There are two methods for lossless rotation of JPEG images:
1. Reorganising the JPEG blocks (and resetting the EXIF orientation tag to the default value "1" if necessary).
Drawback: Works only then really lossless if the image size is an integer multiple of the JPEG block size (usually 8 pixels; with color subsampling 16 pixels). Otherwise up to 15 pixels at the right or lower image border are cropped.
2. Only changing the EXIF orientation tag (see e.g. here:
http://sylvana.net/jpegcrop/exif_orientation.html)
Drawback: Older software (and maybe poor current software) does not respect the EXIF orientation tag.
It is not possible to use both at the same time, so there should not be two îndependent options.
Actually there is no reason for not using method 1 if it's possible without cropping. The question is what to do if this method is not possible: Either ask the user what to do, use method 2, perform a lossy rotation with recompressing the image, or use method 1 anyway and allow some cropping.
So the option could look like this:
Code: Select all
Method for lossless JPEG rotation:
X JPEG block reorganisation
If this method will crop the image:
X Ask user what to do
O Only change the EXIF orientation tag
O Perform a lossy rotation with recompressing the image
O Allow cropping of up to 15 pixels at the right and lower border
O Only change the EXIF orientation tag
Re: Lossless rotate question
Posted: Thu Sep 23, 2010 6:18 pm
by drugo
JohnFredC wrote:Hi drugo...
Lossless rotation applies only to jpgs and other formats that use a "lossy" compression algorithm.
In order to reduce file size when saving the image to disk, the jpeg engine compresses the image data in a "lossy" manner... this means that the engine discards image information (either pixel position or color or both) in order to make the saved image file smaller. Conversely, when expanding the image out of the file to the display, the jpeg engine "estimates" the lost data and attempts to restore the image to as close to the original (in appearance) as it can. Naturally, since image data has been discarded, the original cannot never be completely restored.
The important thing to remember is that every time one loads a jpg and then saves it, more data is discarded. Eventually the loss of original image data becomes quite noticeable to the eye.
"Lossless rotation" attempts to avoid the loss of quality that happens when the file is saved (after the rotation has been applied). Lossless rotation takes into account mathematical characteristics of the jpeg compression to allow image rotation to occur "in place" (that is, without recompression) for images whose horizontal and vertical dimensions meet certain criteria.
So... use lossless rotation on jpgs.
I always recommend that one convert images from jpg to a lossless compression format (tiff, or png, or psd) before starting the editing/adjustment process. When the images have been rotated, corrected, or otherwise modified to the extent required, then (and only then) should the user convert them back to jpg for distribution as smaller files. (Lossless compression tends to make much large files than lossy compression does).
This topic has been discussed several times previously in the forum. It is actually more complicated than presented here, but you get the idea.
thank you so much
Re: Lossless rotate question
Posted: Thu Sep 23, 2010 6:19 pm
by drugo
Karl02 wrote:Lossless means no loss of image quality.
There are two methods for lossless rotation of JPEG images:
1. Reorganising the JPEG blocks (and resetting the EXIF orientation tag to the default value "1" if necessary).
Drawback: Works only then really lossless if the image size is an integer multiple of the JPEG block size (usually 8 pixels; with color subsampling 16 pixels). Otherwise up to 15 pixels at the right or lower image border are cropped.
2. Only changing the EXIF orientation tag (see e.g. here:
http://sylvana.net/jpegcrop/exif_orientation.html)
Drawback: Older software (and maybe poor current software) does not respect the EXIF orientation tag.
It is not possible to use both at the same time, so there should not be two îndependent options.
Actually there is no reason for not using method 1 if it's possible without cropping. The question is what to do if this method is not possible: Either ask the user what to do, use method 2, perform a lossy rotation with recompressing the image, or use method 1 anyway and allow some cropping.
So the option could look like this:
Code: Select all
Method for lossless JPEG rotation:
X JPEG block reorganisation
If this method will crop the image:
X Ask user what to do
O Only change the EXIF orientation tag
O Perform a lossy rotation with recompressing the image
O Allow cropping of up to 15 pixels at the right and lower border
O Only change the EXIF orientation tag
thanks a lot
Re: Lossless rotate question
Posted: Mon Oct 21, 2013 5:22 pm
by drugo
may i ask a question ?
but this feature in the screeshot is Lossless ?

Re: Lossless rotate question
Posted: Mon Oct 21, 2013 5:26 pm
by drugo
JohnFredC wrote:Hi drugo...
Lossless rotation applies only to jpgs and other formats that use a "lossy" compression algorithm.
.
but the author of the program said
No it's a different choice. You have lossless rotation (which change picture data), and EXIF orientation field
do i miss something?
thanks
Re: Lossless rotate question
Posted: Mon May 25, 2015 6:51 pm
by Karl02
No change in XnView v2.32 (2015-03-16).
The options are displayed under Browser > Misc. > Rotation as follows:
Code: Select all
[ ] Keep original date/time attributes
[ ] Change EXIF orientation ONLY when possible (JPEG)
[ ] Use Lossless rotation when possible (JPEG)
They refer to the saving of rotated JPEG images. So they would better fit under General > Read/Write > JPEG > Rotation as follows (default):
Code: Select all
Method for lossless JPEG rotation:
(*) Only change existing or add new EXIF orientation tag
( ) JPEG block transformation
If not all JPEG blocks are transformable:
( ) Allow cropping of up to 15 pixels at the right and/or
lower border of the original image
( ) Keep all pixels of the original image
( ) Only change existing or add new EXIF orientation tag
( ) Perform a lossy rotation with recompressing the image
(*) Ask user what to do
[X] Set EXIF orientation tag to "1" after JPEG block transformation
[X] Create backup file
[ ] Keep original file modification date/time
These options should also be shown in the JPEG Lossless Transformations dialog window (directly or after clicking an "Options" button). See the following picture:

- xnview_2.32_JPEG_Lossless_Transformations.png (8.55 KiB) Viewed 5268 times
There should be an additional option:
[ ] Save current settings as defaults
Perhaps there could also be a preview window to see how the image will look after the transformation.
Here is a demo program for lossless JPEG rotate and crop:
http://sylvana.net/jpegcrop/
Re: Lossless rotate question
Posted: Tue Jun 09, 2015 2:55 pm
by Karl02
I've created a new set of testimages for testing the lossless JPEG rotation.
Preview:
Specifications:
- colored borders with a width of 22 pixels
- JPEG block size is 16 pixels for chrominance (color subsampling 4:2:0)
- width and height are different and not a multiple of the JPEG block size (239 x 255 for normal orientation)
- JPEG optimized and progressive
- embedded thumbnails
- 4 different EXIF dates with different seconds:
-- 01) 0x9003 DateTimeOriginal
-- 02) 0x9004 DateTimeDigitized (CreateDate in ExifTool)
-- 03) 0x0132 ModifyDate for main image
-- 04) 0x0132 ModifyDate for thumbnail image
Download:
Test in jpegcrop:
Re: Lossless rotate question
Posted: Tue Jan 05, 2016 11:41 pm
by Karl02
Perhaps it would be easier to avoid separate lossy and lossless JPEG transformation functions and use general JPEG transformation functions that work according to the options.
The options for the saving of transformed JPEG images should be in "General > Read/Write > JPEG > Transformation" and look as follows (default):
Code: Select all
Method for JPEG transformations (rotate/flip):
(*) Only change existing or add new EXIF orientation tag
( ) JPEG block transformation
If not all JPEG blocks are transformable:
( ) Allow cropping of up to 15 pixels at the right and/or
lower border of the original image
( ) Keep all pixels of the original image
( ) Only change existing or add new EXIF orientation tag
( ) Perform a lossy rotation with recompressing the image
(*) Ask user what to do
[X] Set EXIF orientation tag to "1" after JPEG block transformation
[X] Create backup file
[ ] Keep original file modification date/time