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 329129 - Rotating garbles image irrecoverably
Rotating garbles image irrecoverably
Status: RESOLVED FIXED
Product: gthumb
Classification: Other
Component: general
2.7.x
Other Linux
: Normal critical
: ---
Assigned To: Paolo Bacchilega
Paolo Bacchilega
: 141588 406794 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-01-29 21:57 UTC by Evert Verhellen
Modified: 2007-02-11 19:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Original image (27.65 KB, image/jpeg)
2006-01-29 21:58 UTC, Evert Verhellen
Details
Rotated image (magnified) (69.89 KB, image/png)
2006-01-29 21:59 UTC, Evert Verhellen
Details

Description Evert Verhellen 2006-01-29 21:57:52 UTC
Steps:

 1. Open the attached image in gThumb.
 2. Rotate 90 degrees counterclockwise.

Actual results:
The image rotates. However, the 4 left-most lines of the original image are garbled in the end result. Meaning data loss and therefore a critical bug.

Expected results:
A perfectly rotated image.

Version: gThumb 2.7.2
Comment 1 Evert Verhellen 2006-01-29 21:58:42 UTC
Created attachment 58355 [details]
Original image
Comment 2 Evert Verhellen 2006-01-29 21:59:25 UTC
Created attachment 58356 [details]
Rotated image (magnified)
Comment 3 Evert Verhellen 2006-04-04 17:38:08 UTC
 Still the same in 2.7.3.
Comment 4 Evert Verhellen 2006-04-05 15:56:59 UTC
And also in 2.7.5.1.
Comment 5 Paolo Bacchilega 2006-04-14 09:23:06 UTC
I'm not sure there is data loss here, if you rotate back the image seems to be restored correctly.
Comment 6 Evert Verhellen 2006-04-14 15:46:36 UTC
You're right, the original image can be recovered this way. However, my intent is to print rotated images ... Still a major bug because gThumb prevents me from doing so.
Comment 7 Evert Verhellen 2006-06-17 07:41:01 UTC
Version 2.7.7 still exhibits the bug.
Comment 8 Michael Chudobiak 2006-09-15 20:12:01 UTC
I don't think this is a gthumb bug, exactly. Running:

jpegtran -rot 270 nano_4514.jpg > rot.jpg

produces the same problem (garbled edge), so I think the problem is either:

1) There is something wrong with the sample file.
2) There is something wrong with the libjpeg / jpegtran code.

Can you reproduce this on any other images? 
Comment 9 Michael Chudobiak 2006-09-20 12:52:28 UTC
OK, after a little research: truly lossless jpeg rotation is only possible if the vertical and horizontal dimensions are both multiples of 8 (jpeg MCU = minimum coded unit = 8). For details, see the jpegtran man page, http://www.impulseadventure.com/photo/rotation-partial-mcu.html, and http://www.impulseadventure.com/photo/lossless-rotation.html.

If the dimensions are not multiples of 8, the program has three basic options:

1) Crop the photo to the nearest multiple of 8 (jpegtran -trim option), or,
2) Garble the edges slightly, or,
3) Use the "generic" rotate options (swap x and y and save, with re-compression)

All approaches result in data loss!

Currently gthumb opts for #2. In contrast, xnview opts for #1 (cropping), with a warning.

I think that images with 8x8 multiples should use the jpeg lossless rotate, but all other images should use the generic rotate routine (#3), to keep it simple for normal users.

What do other people think?
Comment 10 Michael Chudobiak 2006-09-20 13:24:36 UTC
Maybe gthumb should offer the choice of a "lossless" cropped rotate for odd-size jpeg images, or "lossy" rotate with a compression-quality slider (and just use the lossless rotate automatically for 8x8 jpegs).
Comment 11 Michael Chudobiak 2006-09-20 18:55:57 UTC
*** Bug 141588 has been marked as a duplicate of this bug. ***
Comment 12 Michael Chudobiak 2006-10-11 12:12:06 UTC
This is fixed in CVS (head).

If the image has an Exif orientation tag, and the image dimensions are not multiples of 8, then Tools>Rotate will change the orientation tag to accomplish the rotation (overriding the selected rotation mode, if necessary).

The sample image above does have an Exif orientation tag, so it can be losslessly rotated by changing the tag.

If the image does not have an Exif orientation tag, and the image dimensions are not multiples of 8, then data loss is unavoidable.
Comment 13 Michael Chudobiak 2007-02-11 19:37:01 UTC
*** Bug 406794 has been marked as a duplicate of this bug. ***