After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 455883 - Rotate left + Save: Error in last line of new image
Rotate left + Save: Error in last line of new image
Status: RESOLVED OBSOLETE
Product: eog
Classification: Core
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: EOG Maintainers
EOG Maintainers
: 577142 603304 793049 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-07-11 12:35 UTC by Rafael Gattringer
Modified: 2021-06-19 08:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Original JPG Image (227.99 KB, image/jpeg)
2007-07-11 12:36 UTC, Rafael Gattringer
Details
Image showing error at the last line (226.66 KB, image/jpeg)
2007-07-11 12:37 UTC, Rafael Gattringer
Details
original and padded (200% zoomed) (63.68 KB, image/png)
2010-10-16 12:37 UTC, Oliver Joos
Details

Description Rafael Gattringer 2007-07-11 12:35:15 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.
Comment 1 Rafael Gattringer 2007-07-11 12:36:50 UTC
Created attachment 91616 [details]
Original JPG Image
Comment 2 Rafael Gattringer 2007-07-11 12:37:43 UTC
Created attachment 91617 [details]
Image showing error at the last line
Comment 3 Rafael Gattringer 2007-07-11 12:42:36 UTC
Bug noticed on Ubuntu Feisty 7.04 / EOG 2.18.1 and also replicated on Ubuntu Dapper 6.06 / EOG 2.14.3.
Comment 4 Felix Riemann 2007-07-11 15:36:24 UTC
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.
Comment 5 Claudio Saavedra 2007-08-11 04:40:38 UTC
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.
Comment 6 Felix Riemann 2007-08-19 19:11:52 UTC
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)?
Comment 7 Claudio Saavedra 2009-03-29 10:43:36 UTC
*** Bug 577142 has been marked as a duplicate of this bug. ***
Comment 8 Marcel Stimberg 2010-10-10 21:11:43 UTC
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".
Comment 9 Oliver Joos 2010-10-16 12:37:17 UTC
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.
Comment 10 Felix Riemann 2010-10-16 17:29:21 UTC
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.
Comment 11 Felix Riemann 2010-10-16 21:18:10 UTC
*** Bug 603304 has been marked as a duplicate of this bug. ***
Comment 12 Marcel Stimberg 2010-10-17 13:01:56 UTC
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...
Comment 13 Kevin Hagner 2017-11-19 19:25:43 UTC
Issue still existing with eog 3.26.1.
Comment 14 Felix Riemann 2018-05-31 12:53:04 UTC
*** Bug 793049 has been marked as a duplicate of this bug. ***
Comment 15 André Klapper 2021-06-19 08:47:34 UTC
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.