Bug 132352 - gwenview incorrectly saves rotated images
Summary: gwenview incorrectly saves rotated images
Status: RESOLVED FIXED
Alias: None
Product: gwenview
Classification: Applications
Component: general (show other bugs)
Version: 2.7
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Gwenview Bugs
URL:
Keywords:
: 153066 252693 273417 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-13 17:48 UTC by Matěj Laitl
Modified: 2017-09-09 13:36 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Original Image (102.63 KB, image/jpeg)
2006-08-13 17:51 UTC, Matěj Laitl
Details
Rotated Image (104.30 KB, image/jpeg)
2006-08-13 17:54 UTC, Matěj Laitl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matěj Laitl 2006-08-13 17:48:25 UTC
Version:           1.3.92 (using KDE KDE 3.5.3)
Installed from:    Gentoo Packages
Compiler:          GCC 4.1 
OS:                Linux

This bug applies to *SOME* JPEGs.
When I try rotate a jpeg image, it displays correctly.
But when I save it, a thin row of pixels (usually 5 to 10 pixels thick - depends on the image) is magically transfered from top to bottom. (or other directions)

If I rotate the original image, but save it in PNG instead of JPEG, the problem is gone.

This problem also aplies to Flip and Mirror operations.

This seems related to new JPEG lossles rotation capability introduced in 1.3.92

I'm gonna upload images where this occurs.

I checked it in GV versions: 1.3.92 and SVN revison 572689 (dated 2006-08-13)
Comment 1 Matěj Laitl 2006-08-13 17:51:06 UTC
Created attachment 17356 [details]
Original Image
Comment 2 Matěj Laitl 2006-08-13 17:54:22 UTC
Created attachment 17357 [details]
Rotated Image

Note the image only seems to be B/W. Technically it's full RGB.

PS: Like the girls? ;-)
Comment 3 Thomas Schildknecht 2006-09-19 02:45:10 UTC
Same problem here with this picture : http://danakil.free.fr/linux/bug_if_rotated.jpg
http://danakil.free.fr/linux/right_rotated.jpg   -> bug

I don't know if this is important but this picture was resized with the "Resize images..." kipi plugin
Comment 4 Matěj Laitl 2006-10-31 19:30:13 UTC
Still occurs with gwenview 1.4.0 using KDE 3.5.5
Comment 5 Aurelien Gateau 2006-11-03 15:43:12 UTC
This is because the JPEG image dimensions are not a multiple of the MCU size see [1] for an explanation). In this case, there are three solutions to perform a rotation:

1: Apply a lossless rotation, keeping the odd pixels around. Rotating the image the other way will give you back the original image.

2: Apply a lossless rotation, but trim the offending pixels, in your case this would reduce the height of the rotated image from 900 to 896. Rotating the image the other way won't give you back the original image.

3: Apply a lossy rotation, which would give a correct image, but would probably loose some details.

For now, Gwenview adopts a conservative behavior and use #1. What do you think should be done? let the user choose the solution? select #2 or #3 without asking?

If you want to try #2, edit imageutils/jpegcontent.cpp, find the line that says:

  transformoption.trim = false;

and change it to:

  transformoption.trim = true;

[1]: http://www.impulseadventure.com/photo/jpeg-minimum-coded-unit.html
Comment 6 Matěj Laitl 2006-11-03 17:48:21 UTC
Oh, thanks for the nice explanation...

Is it possible to apply a lossy rotation only to the partial MCUs on the sides, while keeping lossless for the rest? Looks like a good compromise for me.

Trimming an image a little (the worst case would be 15 pixels) is not IMHO transparent for user... It alters composition or user-made margins etc.

How often you rotate & save multiple times? I prefer small quality loss to erasing a small part of image.

(maybe stupid) idea: If it saved rotated JPEGs with slightly lower compression ratio, would it eliminate the quality loss?
Comment 7 Matěj Laitl 2006-11-03 18:00:35 UTC
Oh, now I know that i can't be only partially lossy.

So the best solution IMHO:
offer 2 or 3 to an user, and add configuration options: 
  always 2.
  always 3.
  ask before each save of rotated odd-sized jpeg.

what about the "maybe stupid idea"?

Now i will only resize my JPEGs to multiples of 8.
Comment 8 Aurelien Gateau 2006-11-07 11:40:31 UTC
Thanks for your suggestions, I will think about it.

As of your "maybe stupid idea": I think it could compensate for some quality loss, but it won't eliminate it and would of course result in a larger file.
Comment 9 Rich Johnson 2006-12-06 19:49:04 UTC
This same bug/issue also occurs for me with .eps files. A bug has been reported on the Ubuntu Bug Tracker (Malone) concerning this as well.

https://launchpad.net/distros/ubuntu/+source/gwenview/+bug/29627

Using:
 Gwenview 1.4.0
 KDE 3.5.5
Comment 10 Alex Naumov 2010-08-25 12:57:57 UTC
Hi guys,

the same here. KDE 4.5, openSUSE 11.3.

> rpm -qa gwenview
gwenview-4.5.0-170.2.i586


What's about patch or something like this?
Comment 11 Kai Uwe Broulik 2010-12-24 13:37:16 UTC
I found a solution for myself: Rotating the image, then cutting the out-of-place-part, flipping it (since it is upside down), and attaching it to the top. -> done :D
Still annoying.
Comment 12 Alexander van Loon 2011-11-12 08:38:43 UTC
Any news on this? Because I just witnessed this bug occur with Gwenview 2.7.2 on KDE 4.7.3.
Comment 13 Octavian Petre 2011-11-12 21:37:47 UTC
gwenview 2.6.4 on KDE 4.6.5 is OK
Comment 14 Mark S. 2011-12-27 23:57:35 UTC
With Gwenview 2.7.4 on KDE 4.7.4, I can still reproduce this bug using Matěj Laitl's original pictures.
Comment 15 Myriam Schweingruber 2012-01-02 21:38:56 UTC
*** Bug 153066 has been marked as a duplicate of this bug. ***
Comment 16 Aurelien Gateau 2012-01-06 08:35:47 UTC
*** Bug 273417 has been marked as a duplicate of this bug. ***
Comment 17 Aurelien Gateau 2012-01-06 08:36:05 UTC
*** Bug 252693 has been marked as a duplicate of this bug. ***
Comment 18 Martin Klapetek 2013-06-21 15:19:57 UTC
Still present in 4.10.3.
Comment 19 Nate Graham 2017-09-09 13:36:10 UTC
I'm not able to reproduce this with Matěj's original image as of Gwenview 16.12.3 or 17.11.70. Looks fixed!