Bug 349180

Summary: resizing attached images corrupts the images
Product: [Applications] kmail2 Reporter: Martin Koller <kollix>
Component: composerAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: aheinecke, montel
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 4.14.10
Sentry Crash Report:

Description Martin Koller 2015-06-15 12:13:00 UTC
I have some JPEG files attached, and kmail asks if I want to resize them when sending (I have configured to ask me).
I accept and kmail changes the files - however this has some faults:
1.) My .jpg files are still named .jpg, but kmail did actually create PNG files !
2.) The exif rotation information is not taken into account, that means, all images which were photograped up-side-down, are now also saves 180 degree rotated, but an image viewer can no longer correctly display them.

Reproducible: Always



Expected Results:  
Keep jpg file and keep exif information
Comment 1 Laurent Montel 2015-06-15 21:04:29 UTC
Indeed there is some bugs.
But "create PNG files " look at your config by default we can save as PNG or JPG so perhaps it's configurate as PNG.

exif rotation exists in png ?
Comment 2 Laurent Montel 2015-06-16 04:56:28 UTC
Git commit b9d88a5f1b2d2a814572437c32b456cceb22fa23 by Montel Laurent.
Committed on 16/06/2015 at 04:55.
Pushed by mlaurent into branch 'KDE/4.14'.

Fix Bug 349180 - resizing attached images corrupts the images

Rename image when we change extension.

M  +2    -0    messagecomposer/composer/composer.cpp
M  +25   -1    messagecomposer/imagescaling/imagescaling.cpp
M  +4    -0    messagecomposer/imagescaling/imagescaling.h

http://commits.kde.org/kdepim/b9d88a5f1b2d2a814572437c32b456cceb22fa23
Comment 3 Laurent Montel 2015-06-16 05:45:53 UTC
Git commit 7b928f3b5f76520960357616e737a9b2f9777d78 by Montel Laurent.
Committed on 16/06/2015 at 05:44.
Pushed by mlaurent into branch 'KDE/4.14'.

Fix Bug 349180 - resizing attached images corrupts the images
FIXED-IN: 4.14.10
Now we don't change image format if not necessary

M  +1    -0    messagecomposer/composer/composer.cpp
M  +29   -7    messagecomposer/imagescaling/imagescaling.cpp
M  +2    -0    messagecomposer/imagescaling/imagescaling.h
M  +1    -1    messagecomposer/imagescaling/ui/imagescalingwidget.ui

http://commits.kde.org/kdepim/7b928f3b5f76520960357616e737a9b2f9777d78
Comment 4 Martin Koller 2015-06-16 05:51:25 UTC
Interestingly my setting is JPG, still kmail saves as PNG

According to wikipedia PNG does not support exif - but that doesn't matter as long as the image conversion in kmail uses the exif information in the given JPG file, rotates it internally correctly and  *then* scales it down and saves it as PNG

Another issue is that kmail asks me to resize images even though the images are already small enough and do not need resize (e.g. max is set to 1280 x 1280, attachment is 1280 x 1024, and in addition the attached image is lower in size (167kB) than the defined setting (220kB)
Comment 5 Laurent Montel 2015-06-16 09:17:58 UTC
"interestingly my setting is JPG, still kmail saves as PNG"  wierd.

"According to wikipedia PNG does not support exif - but that doesn't matter as long as the image conversion in kmail uses the exif information in the given JPG file, rotates it internally correctly and *then* scales it down and saves it as PNG" I use QImage method. So I don't know if it can do it.

"Another issue is that kmail asks me to resize images even though the images are already small enough and do not need resize (e.g. max is set to 1280 x 1280, attachment is 1280 x 1024, and in addition the attached image is lower in size (167kB) than the defined setting (220kB)"
need a new unittest.

I started to add more unittest and try to fix all bug from it.
Comment 6 Martin Koller 2015-06-16 16:22:31 UTC
Regarding exif: I'm using the following lines in my imageviewer "showimage":
( http://kde-apps.org/content/show.php?content=143977 )

QImage image;
image.load(sourceUrl.path())

KExiv2Iface::KExiv2 exif(sourceUrl.path());
exif.rotateExifQImage(image, exif.getImageOrientation());

In the cmake file, just use
find_package(Kexiv2 REQUIRED)
 ${KEXIV2_INCLUDE_DIR}
 ${KEXIV2_LIBRARIES})
Comment 7 Laurent Montel 2015-06-17 04:33:30 UTC
I don't want to add more dependancy but I will investigate it if I can use it.
Comment 8 Andre Heinecke 2015-06-25 14:52:17 UTC
Git commit be886ddf9397ab1ee40a075a1ee34c5c42dea038 by Andre Heinecke.
Committed on 25/06/2015 at 14:47.
Pushed by aheinecke into branch 'KDE/4.14'.

Do not try to get audit log for erroneous contexts

On error gpgme closes the assuan context of the
gpgme context. Calling getAuditLog on a closed context
leads to a crash.
REVIEW: 124175
FIXED-IN: 4.14.10

M  +1    -1    libkleo/backends/qgpgme/threadedjobmixin.cpp

http://commits.kde.org/kdepim/be886ddf9397ab1ee40a075a1ee34c5c42dea038
Comment 9 Laurent Montel 2015-06-25 15:01:53 UTC
????? :)
Comment 10 Andre Heinecke 2015-06-26 11:02:11 UTC
woops, sorry I accidentally used the wrong bug number in my commit.
Comment 11 Denis Kurz 2016-09-24 18:15:31 UTC
This bug has only been reported for versions before 4.14, which have been unsupported for at least two years now. Can anyone tell if this bug still present?

If noone confirms this bug for a Framework-based version of kmail2 (version 5.0 or later, as part of KDE Applications 15.12 or later), it gets closed in about three months.
Comment 12 Denis Kurz 2017-01-07 22:09:21 UTC
Just as announced in my last comment, I close this bug. If you encounter it again in a recent version (at least 5.0 aka 15.08), please open a new one unless it already exists. Thank you for all your input.