Lossless transformations on others than JPEG
Moderators: helmut, XnTriq, xnview
Lossless transformations on others than JPEG
Some lossless transformations are possible on JPEG. That's good, I like that. But why can't I losslesly rotate a lossless picture? On a losslessly compressed picture, like PNG, any 90-degree rotation, or mirror, is by definition also lossless.
It makes sense that transformations that can be done losslessly on JPEG, can also be done on images that are losslessly compressed. Like PNG, lossless WebP, BMP, GIF, etc.
It makes sense that transformations that can be done losslessly on JPEG, can also be done on images that are losslessly compressed. Like PNG, lossless WebP, BMP, GIF, etc.
Using Windows 10 21H1 and loving it. Cheers!
Re: Lossless transformations on others than JPEG
You mean that there isn't a separate 'lossless rotate' action?
It should be, isn't the general sequence:On a losslessly compressed picture, like PNG, any 90-degree rotation, or mirror, is by definition also lossless.
The source image when opened is converted losslessly to the full pixel matrix;
The rotation is performed losslessly if an appropriate algorithm is used;
The rotated image matrix is saved using a lossless compression method.
So isn't it understood that, provided an appropriate rotation algorithm is used, and the image is resaved using lossless compression, the rotation will be lossless?
Re: Lossless transformations on others than JPEG
No, this *only* works on JPEG, and *no other* image format whatsoever.You mean that there isn't a separate 'lossless rotate' action?
Absolutely. A lossless operation on a lossless picture is always lossless.So isn't it understood that, provided an appropriate rotation algorithm is used, and the image is resaved using lossless compression, the rotation will be lossless?
If you rotate your car, it's still the same car. You don't compress it.
Now as for JPEG lossless operations, can we please have them on lossless file formats too, please?
Using Windows 10 21H1 and loving it. Cheers!
Re: Lossless transformations on others than JPEG
Sorry, which JPEG lossless operations are you referring to, could you please give some examples...thany2 wrote: Fri Nov 13, 2020 3:20 pm Now as for JPEG lossless operations, can we please have them on lossless file formats too, please?
Re: Lossless transformations on others than JPEG
See my TS

90-degree rotation and mirror.
Using Windows 10 21H1 and loving it. Cheers!
Re: Lossless transformations on others than JPEG
Isn't a lossless JPEG operation an operation in which the resulting image matrix is saved in a way that avoids introducing additional encoding artifacts?thany2 wrote: Fri Nov 13, 2020 3:20 pm Now as for JPEG lossless operations, can we please have them on lossless file formats too, please?
But that issue doesn't arise with a lossless file format, the conversion is lossless provided a suitable algorithm is used, and saving is lossless...
Wikipedia - JPEG - Lossless editing
Re: Lossless transformations on others than JPEG
Exactly my reasoning for having these transformations available for lossless formats in addition to JPEG.cday wrote: Fri Nov 27, 2020 9:37 amIsn't a lossless JPEG operation an operation in which the resulting image matrix is saved in a way that avoids introducing additional encoding artifacts?thany2 wrote: Fri Nov 13, 2020 3:20 pm Now as for JPEG lossless operations, can we please have them on lossless file formats too, please?
But that issue doesn't arise with a lossless file format, the conversion is lossless provided a suitable algorithm is used, and saving is lossless...
Wikipedia - JPEG - Lossless editing
Using Windows 10 21H1 and loving it. Cheers!
Re: Lossless transformations on others than JPEG
I'm sorry, I don't understand, where exactly can loss be introduced when converting and resaving an image in a lossless format??
Re: Lossless transformations on others than JPEG
As I see this, the lossless transformation tool works just fine as it is, doing what it was designed for.
Re: Lossless transformations on others than JPEG
The lossless transformation tool only works for JPEG, I'm asking to enable it also for lossless formats.cday wrote: Fri Nov 27, 2020 10:25 am I'm sorry, I don't understand, where exactly can loss be introduced when converting and resaving an image in a lossless format??
Same answer.mudo_j wrote: Fri Nov 27, 2020 5:49 pm As I see this, the lossless transformation tool works just fine as it is, doing what it was designed for.
Using Windows 10 21H1 and loving it. Cheers!
Re: Lossless transformations on others than JPEG
This seems to be still a bit of wild jungle out there. Here is my observations of lossless rotations:
- there is 3 different tags that might specify lossless rotation, 1. "orientation", 2. "rotation", 3. "cameraorientation"
- orientation is typically part of EXIF data and typically is modifiable (although I run into couple of cases where exiftool was unable to modify it. The "JPEG lossless rotation" if I have not understood incorrectly is simply modifying value in EXIF orientation field and pic viewers then rotate the pic if orientation is anything else than 0 degrees (90, 180, or 270 degrees)
- rotation is less commonly used for still images but HEIC images (iphones) is the large exception. For videos (MP4) rotation seems to be widely used and viewers in general use rotation field to decide how to display the video. Rotation for still images is NOT modifiable in any easy way.
- some digicams save direction to both orientation and cameraorientation. Some save only to cameraorientation which can cause issues when rendering image.
HEIC:
- my phone (S21FE) when taking portrait pic saves value to BOTH orientation and rotation fields. I would assume that maybe same is for iphone HEICs but hopefully somebody here can confirm?
- problems start to arise because only orientation seems to be modifiable but some apps use rotation when rendering and some use orientation. These programs seem to use rotation: XNView MP, MS Photos, Affinity Photo. These programs seem to use orientation: majority of android gallery apps
AVIF:
- currently majority of viewers ignore orientation tag but Samsung Gallery is exception that respects it
JXL:
- MS Photos respect orientation tag, XNView MP ignores it
DNG:
- don't remember anymore which programs use which tag but I assume that probably orientation? Anyway I got this solved by bat file which modifies both in rare situations where I need to rotate a file.
So how this situation should be dealt with? Maybe first read some standards how they specify lossless rotations. Also problem is that no cameras save yet AVIF or JXL pics so there is not yet a large need (except among us who wants to do archiving projects a bit early)
- "enable reading and modifying orientation/rotation for modern file formats"
When this setting is enabled you can
1. apply lossless rotation in addition to JPEG at least to 1. HEIC, 2. AVIF, 3. JXL, 4. maybe others? (dng, webp)
2. when HEIC is rendered renderer reads orientation tag instead of rotation tag
3. when AVIF, JXL, others are rendered orientation tag is read and respected
Lossless rotation is important when you archive large amount of pics but don't have time to search through them for wrong rotations and maybe notice wrong rotation years after and want to rotate without re-encoding (if you pushed hard in first encoding then re-encoding just for 90 deg rotation might be the one step that brings visible artifacts)
Here is what ChatGPT answered about the subject.
- there is 3 different tags that might specify lossless rotation, 1. "orientation", 2. "rotation", 3. "cameraorientation"
- orientation is typically part of EXIF data and typically is modifiable (although I run into couple of cases where exiftool was unable to modify it. The "JPEG lossless rotation" if I have not understood incorrectly is simply modifying value in EXIF orientation field and pic viewers then rotate the pic if orientation is anything else than 0 degrees (90, 180, or 270 degrees)
- rotation is less commonly used for still images but HEIC images (iphones) is the large exception. For videos (MP4) rotation seems to be widely used and viewers in general use rotation field to decide how to display the video. Rotation for still images is NOT modifiable in any easy way.
- some digicams save direction to both orientation and cameraorientation. Some save only to cameraorientation which can cause issues when rendering image.
HEIC:
- my phone (S21FE) when taking portrait pic saves value to BOTH orientation and rotation fields. I would assume that maybe same is for iphone HEICs but hopefully somebody here can confirm?
- problems start to arise because only orientation seems to be modifiable but some apps use rotation when rendering and some use orientation. These programs seem to use rotation: XNView MP, MS Photos, Affinity Photo. These programs seem to use orientation: majority of android gallery apps
AVIF:
- currently majority of viewers ignore orientation tag but Samsung Gallery is exception that respects it
JXL:
- MS Photos respect orientation tag, XNView MP ignores it
DNG:
- don't remember anymore which programs use which tag but I assume that probably orientation? Anyway I got this solved by bat file which modifies both in rare situations where I need to rotate a file.
So how this situation should be dealt with? Maybe first read some standards how they specify lossless rotations. Also problem is that no cameras save yet AVIF or JXL pics so there is not yet a large need (except among us who wants to do archiving projects a bit early)
- "enable reading and modifying orientation/rotation for modern file formats"
When this setting is enabled you can
1. apply lossless rotation in addition to JPEG at least to 1. HEIC, 2. AVIF, 3. JXL, 4. maybe others? (dng, webp)
2. when HEIC is rendered renderer reads orientation tag instead of rotation tag
3. when AVIF, JXL, others are rendered orientation tag is read and respected
Lossless rotation is important when you archive large amount of pics but don't have time to search through them for wrong rotations and maybe notice wrong rotation years after and want to rotate without re-encoding (if you pushed hard in first encoding then re-encoding just for 90 deg rotation might be the one step that brings visible artifacts)
Here is what ChatGPT answered about the subject.
Re: Lossless transformations on others than JPEG
More observations:
- MS Photos is able to do lossless rotation for HEIC / AVIF files (it modifies rotation metadata). But it does NOT modify orientation metadata.
- If avif has both rotation and orientation samsung gallery seems to prioritize/use avif rotation.
Optimally when modifying these file formats both should be changed but HEIC/AVIF rotation seems not simple as it was written in exiftool forum that rotation cant be (at least yet) modified. Nevertheless one half of this can now be solved with MS photos (and orientation possibly with exiftool).
Regarding JXL it would be cool to get an option for XNView MP to respect orientation data in JXL file.
- MS Photos is able to do lossless rotation for HEIC / AVIF files (it modifies rotation metadata). But it does NOT modify orientation metadata.
- If avif has both rotation and orientation samsung gallery seems to prioritize/use avif rotation.
Optimally when modifying these file formats both should be changed but HEIC/AVIF rotation seems not simple as it was written in exiftool forum that rotation cant be (at least yet) modified. Nevertheless one half of this can now be solved with MS photos (and orientation possibly with exiftool).
Regarding JXL it would be cool to get an option for XNView MP to respect orientation data in JXL file.