GNOME Bugzilla – Bug 455883
Rotate left + Save: Error in last line of new image
Last modified: 2021-06-19 08:47:34 UTC
Please describe the problem: Rotate a jpg photo left and save it. The last line of the new picture will display incorrect pixels. Steps to reproduce: 1. Rotate a (jpeg) file once left. 2. Save the picture. Actual results: The last line of the new image displays incorrect pixels. Expected results: Same output as rotating and saving the image with GIMP. Does this happen every time? Yes. Other information: - Seems not to occur after rotating right. - Ok with other jpg files.
Created attachment 91616 [details] Original JPG Image
Created attachment 91617 [details] Image showing error at the last line
Bug noticed on Ubuntu Feisty 7.04 / EOG 2.18.1 and also replicated on Ubuntu Dapper 6.06 / EOG 2.14.3.
Indeed. This appears to be related to the lossless JPG transformations as it is reproducible with jpegtran. I don't know if there is anything against it we can do inside EOG. A workaround would be to save the rotated image in PNG-format (lossless) and then save the PNG-File as a JPG again.
I can reproduce it as well. These pixels are not really wrong, but they correspond to the opposite row (or column). If this is inside libjpeg we should report it against it.
Hmm, I don't think this is a problem with libjpeg but with lossless jpeg transformations in general. It could be what Alan Horkan talks about in bug 338138 comment 9 (first paragraph). Rotating the image would apparently require trimming the image to a multiple of 16. The question is: Can we detect this and warn the user (and possibly let him decide what to do)?
*** Bug 577142 has been marked as a duplicate of this bug. ***
From the JPEG FAQ: > In particular it is possible to do 90-degree rotations and > flips losslessly, if the image dimensions are a multiple of the file's > block size (typically 16x16, 16x8, or 8x8 pixels for color JPEGs). In contrast to eog, gthumb does detect this situation and displays a dialog with the following text: This transformation may introduce small image distortions along one or more edges, because the image dimensions are not multiples of 8. The distortion is reversible, however. If the resulting image is unacceptable, simply apply the reverse transformation to return to the original image. You can also choose to discard (or trim) any untransformable edge pixels. For practical use, this mode gives the best looking results, but the transformation is not strictly lossless anymore. It then gives the options: "Trim", "Cancel" and "Accept distortions".
Created attachment 172489 [details] original and padded (200% zoomed) I would like such a behavior like in gthumb. But why trimming?? I'd prefer padding, namely adding a border (in background color or in black if none is specified). With trimming the rotation is definitely not lossless anymore, with padding it is! After my tests, I guess that perhaps only the width must be rounded up, but to a multiple of 16 (and not 8 as written above). The border should be added on the right edge. On the other hand this might only be correct for JPEGs created by GIMP. I did not consult the specs of JPEG or "lossless rotation"! Further I think that padding should be the default answer in the dialog. Not many people will want distortions. The dialog should have a checkbox "remember my decision and don't ask again". And afterwards the chosen "rotation method" should be changeable in the preferences of eof.
Marcel, such a dialog might indeed be a solution. Not sure yet, if we should act proactively (width%8 != 0 -> not lossless) or whether we should still try to save and check if libjpeg complains (it can be configured to do so since v7) until showing the dialog. We likely need to change how saving works to implement either variant though. Oliver, padding won't necessarily make the rotation lossless since it will trigger the recompression of the image which is normally what you want to avoid when talking about "lossless JPEG transformations". While trimming isn't really lossless either it works without recompressing the remainder of the picture.
*** Bug 603304 has been marked as a duplicate of this bug. ***
One more thing that came up in the downstream discussion: Most users don't care about a physical rotation of the image, just changing the orientation flag in the EXIF data and thereby changing how the image is displayed would be enough. This "rotation" is obviously always lossless and does not depend on the image size. The only problem here is that some applications (e.g. the gnome desktop background) ignore this flag...
Issue still existing with eog 3.26.1.
*** Bug 793049 has been marked as a duplicate of this bug. ***
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/eog/-/issues/ Thank you for your understanding and your help.