Lossless rotation of image

Hello,

I have the following button for the rotation of an image of 180 degree.

While taking a look to the filesize before and after the rotation I have noticed that after the rotation the filesize increased e.g before rotation it was 3.56 MB after rotation 3.57 MB.
Does anyone know why?
And can anyone please tell me if my code is correct for a lossless rotation
Thanks!

@filesonly
Select REGEXP PATTERN "_L"
Image CONVERT ROTATE=180 HERE REPLACE

Not all JPEGs can be rotated losslessly. It's done automatically where possible but it's only possible when the image dimensions allow it to be done.

It's normal for the file size to change slightly even when the rotation is lossless, due to the way JPEG organises the data. (Possibly also due to slightly different ways different programs write the data.)

To tell if it's really lossless, I would rotate the image 180 degrees a second time and then convert both the original and the new version to BMP files and do a byte comparison on them. They should be identical (so long as they were both converted to BMP using the same program).

thank you for the fast response.

This would also help me:

I have pictures upside down in one folder. When clicking on them (only one at a time) I see inside the viewer pane the picture preview. Now if I click inside the viewer pane "rotate right", the picture - BUT ONLY THE PREVIEW, will turn right. Perfect !

If it could be possible to view ALL pictures inside a folder lets say +180 gegrees rotated in the viewer pane that would be just great for me and I dont have to mess around with the original files.
Though I could not see a function in the setups. The only way I could think of would be a filter but I have no knowledge about setting a filter up like this.

oh and I cannot use the EXIF function for turning the picture automatically since I have no EXIF parameter that containes camera orientation

You could use EXIFTool to add the orientation.

Regards, AB

[quote="leo"]Not all JPEGs can be rotated losslessly. It's done automatically where possible but it's only possible when the image dimensions allow it to be done.

It's normal for the file size to change slightly even when the rotation is lossless, due to the way JPEG organises the data. (Possibly also due to slightly different ways different programs write the data.)

To tell if it's really lossless, I would rotate the image 180 degrees a second time[/quote]

In my experience, Opus never does lossless rotation, since the size of an image rotated 180° twice is always different enough that it can't be explained only by the EXIF orientation byte. DOpus has never set an EXIF orientation mark, even though it's able to read it if it is present.

If Opus still does it when possible, as you say, it would be a good idea to warn the user when it will not be lossless or only allow lossless rotations.

Furthermore, EXIFtool always succeeds in lossless EXIF orientation, why Opus wouldn't be able to do that?

EXIFTool always does lossless because, I presume, it just writes an EXIF tag (which the majority of image viewers & web browsers will ignore, so many won't consider that a successful rotation).

I've tested the lossless rotation stuff in Opus with lots of JPEGs and it really does work, where possible. Same with any other tool that tries to losslessly rotate the JPEG image data (rather than changing the EXIF tag).

If you want any changes made, like an option that rotates by changing the EXIF data, or an option which only rotates if it's lossless, then send GPSoftware a feature request and see what they think.