Lossless transformations on others than JPEG

Ideas for improvements and requests for new features in XnView MP

Moderators: helmut, XnTriq, xnview

Post Reply
thany2
Posts: 63
Joined: Mon Apr 29, 2013 9:29 am

Lossless transformations on others than JPEG

Post by thany2 »

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.
Using Windows 10 21H1 and loving it. Cheers!
cday
XnThusiast
Posts: 4394
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Lossless transformations on others than JPEG

Post by cday »

thany2 wrote: Tue Nov 10, 2020 8:59 pm ... why can't I losslessly rotate a lossless picture?
You mean that there isn't a separate 'lossless rotate' action?

On a losslessly compressed picture, like PNG, any 90-degree rotation, or mirror, is by definition also lossless.
It should be, isn't the general sequence:

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?
thany2
Posts: 63
Joined: Mon Apr 29, 2013 9:29 am

Re: Lossless transformations on others than JPEG

Post by thany2 »

You mean that there isn't a separate 'lossless rotate' action?
No, this *only* works on JPEG, and *no other* image format whatsoever.
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?
Absolutely. A lossless operation on a lossless picture is always 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!
cday
XnThusiast
Posts: 4394
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Lossless transformations on others than JPEG

Post by cday »

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?
Sorry, which JPEG lossless operations are you referring to, could you please give some examples...
thany2
Posts: 63
Joined: Mon Apr 29, 2013 9:29 am

Re: Lossless transformations on others than JPEG

Post by thany2 »

cday wrote: Fri Nov 13, 2020 3:36 pm
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?
Sorry, which JPEG lossless operations are you referring to, could you please give some examples...
See my TS ;)
90-degree rotation and mirror.
Using Windows 10 21H1 and loving it. Cheers!
cday
XnThusiast
Posts: 4394
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Lossless transformations on others than JPEG

Post by cday »

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?
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?

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
thany2
Posts: 63
Joined: Mon Apr 29, 2013 9:29 am

Re: Lossless transformations on others than JPEG

Post by thany2 »

cday wrote: Fri Nov 27, 2020 9:37 am
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?
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?

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
Exactly my reasoning for having these transformations available for lossless formats in addition to JPEG.
Using Windows 10 21H1 and loving it. Cheers!
cday
XnThusiast
Posts: 4394
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Lossless transformations on others than JPEG

Post by cday »

I'm sorry, I don't understand, where exactly can loss be introduced when converting and resaving an image in a lossless format??
mudo_j
Posts: 60
Joined: Fri Feb 17, 2017 7:01 pm

Re: Lossless transformations on others than JPEG

Post by mudo_j »

As I see this, the lossless transformation tool works just fine as it is, doing what it was designed for.
thany2
Posts: 63
Joined: Mon Apr 29, 2013 9:29 am

Re: Lossless transformations on others than JPEG

Post by thany2 »

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??
The lossless transformation tool only works for JPEG, I'm asking to enable it also for lossless formats.
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.
Same answer.
Using Windows 10 21H1 and loving it. Cheers!
golemus
Posts: 65
Joined: Mon Dec 23, 2024 8:35 am

Re: Lossless transformations on others than JPEG

Post by golemus »

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.
Screenshot 2025-05-29 134913.png
Screenshot 2025-05-29 134913.png (104.62 KiB) Viewed 104 times
xnview wrote: Tue Nov 10, 2020 8:59 pm Pierre check this out if you have any insights
golemus
Posts: 65
Joined: Mon Dec 23, 2024 8:35 am

Re: Lossless transformations on others than JPEG

Post by golemus »

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.
Post Reply