Merge lp:~phablet-team/gallery-app/avoid-thumbnailers-from-viewer into lp:gallery-app

Proposed by Ugo Riboni on 2015-01-20
Status: Merged
Approved by: Arthur Mello on 2015-01-21
Approved revision: 1132
Merged at revision: 1130
Proposed branch: lp:~phablet-team/gallery-app/avoid-thumbnailers-from-viewer
Merge into: lp:gallery-app
Diff against target: 114 lines (+20/-23)
5 files modified
rc/qml/MediaViewer/MediaViewer.qml (+0/-5)
rc/qml/MediaViewer/SingleMediaViewer.qml (+1/-17)
src/medialoader/photo-metadata.cpp (+11/-0)
src/medialoader/photo-metadata.h (+5/-0)
src/photo/photo-edit-thread.cpp (+3/-1)
To merge this branch: bzr merge lp:~phablet-team/gallery-app/avoid-thumbnailers-from-viewer
Reviewer Review Type Date Requested Status
Arthur Mello (community) 2015-01-20 Approve on 2015-01-21
PS Jenkins bot continuous-integration Needs Fixing on 2015-01-20
Review via email: mp+246997@code.launchpad.net

Commit Message

Directly downscale the images for the viewer instead of asking the thumbnailer to do it (which it would do incorrectly)

Description of the Change

Directly downscale the images for the viewer instead of asking the thumbnailer to do it (which it would do incorrectly)

To post a comment you must log in.
1131. By Ugo Riboni on 2015-01-20

Use the post-edit reload mechanism built into the photo editor instead of manually doing it from qml

1132. By Ugo Riboni on 2015-01-20

Save the exif thumbnail after editing the image

Arthur Mello (artmello) wrote :

I just tested this branch with r204. The issue related with opening pictures does not happen anymore. Rotation (with undo and back to original) seems to work as expected.

But I think there are some issues with crop:
- On a first crop on an image, when we return to the picture we can still see the original image on the background with the loading spin until the cropped image is loaded. Besides that the first crop works;
- On subsequent crops on the same image there are some strange behaviors. The image displayed is the original one and not the result of the previous crop. The blue rectangle does not always have the size of the previous crop over the original image, on some cases it was smaller than the previously cropped area. Sometimes I was able to increase the cropped area over the previous one but sometimes that was not possible. Besides that, the results of the cropped area seems ok and the thumbnail seems to be updated as expected.

review: Needs Fixing
Arthur Mello (artmello) wrote :

Ok, so I tested the current trunk version of gallery on the same image release and the crop issues are all there. It does not seem to be introduced by this MR.

But I was not able to reproduce the original image on the background with the loading spin while the result of a crop is generated. Not sure if that is a desired behavior.

Ugo Riboni (uriboni) wrote :

The crop issues (for crops after the first) are long standing.
They have been fixed in the external photo editor, which uses a different logic for crop entirely.
I would not bother with them and work on pushing the new editor ASAP after RTM

Arthur Mello (artmello) wrote :

Since neither of the issues are regression this MR does fix the problem and the code lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rc/qml/MediaViewer/MediaViewer.qml'
2--- rc/qml/MediaViewer/MediaViewer.qml 2014-12-17 00:34:42 +0000
3+++ rc/qml/MediaViewer/MediaViewer.qml 2015-01-20 20:19:07 +0000
4@@ -191,11 +191,6 @@
5 }
6
7 onClicked: viewerWrapper.toggleHeaderVisibility()
8-
9- Connections {
10- target: model.mediaSource
11- onDataChanged: media.reload()
12- }
13 }
14
15 // Don't allow flicking while the chrome is actively displaying a popup
16
17=== modified file 'rc/qml/MediaViewer/SingleMediaViewer.qml'
18--- rc/qml/MediaViewer/SingleMediaViewer.qml 2014-10-09 16:08:50 +0000
19+++ rc/qml/MediaViewer/SingleMediaViewer.qml 2015-01-20 20:19:07 +0000
20@@ -56,22 +56,6 @@
21 }
22 }
23
24- function reload() {
25- if (!viewer.isVideo) {
26- var src = image.source
27- image.asynchronous = false
28- image.source = ""
29- image.asynchronous = true
30- image.source = src;
31-
32- src = highResolutionImage.source
33- highResolutionImage.asynchronous = false
34- highResolutionImage.source = ""
35- highResolutionImage.asynchronous = true
36- highResolutionImage.source = src
37- }
38- }
39-
40 function reset() {
41 if (viewer.isVideo) {
42 if (video.item) {
43@@ -151,7 +135,7 @@
44 anchors.fill: parent
45 asynchronous: true
46 cache: false
47- source: mediaSource.galleryPreviewPath
48+ source: mediaSource.galleryPath
49 sourceSize {
50 width: viewer.maxDimension
51 height: viewer.maxDimension
52
53=== modified file 'src/medialoader/photo-metadata.cpp'
54--- src/medialoader/photo-metadata.cpp 2014-12-17 12:20:38 +0000
55+++ src/medialoader/photo-metadata.cpp 2015-01-20 20:19:07 +0000
56@@ -259,6 +259,17 @@
57 }
58 }
59
60+void PhotoMetadata::updateThumbnail(QImage image)
61+{
62+ QImage scaled = image.scaled(image.width() / THUMBNAIL_SCALE,
63+ image.height() / THUMBNAIL_SCALE);
64+ QBuffer jpeg;
65+ jpeg.open(QIODevice::WriteOnly);
66+ scaled.save(&jpeg, "jpeg");
67+ Exiv2::ExifThumb thumb(m_image->exifData());
68+ thumb.setJpegThumbnail((Exiv2::byte*) jpeg.data().constData(), jpeg.size());
69+}
70+
71 /*!
72 * \brief PhotoMetadata::save
73 * \return
74
75=== modified file 'src/medialoader/photo-metadata.h'
76--- src/medialoader/photo-metadata.h 2014-10-24 18:25:32 +0000
77+++ src/medialoader/photo-metadata.h 2015-01-20 20:19:07 +0000
78@@ -29,9 +29,13 @@
79 #include <QString>
80 #include <QSet>
81 #include <QTransform>
82+#include <QImage>
83+#include <QBuffer>
84
85 #include <exiv2/exiv2.hpp>
86
87+#define THUMBNAIL_SCALE 8.5
88+
89 /*!
90 * \brief The PhotoMetadata class
91 */
92@@ -50,6 +54,7 @@
93
94 void setOrientation(Orientation orientation);
95 void setDateTimeDigitized(const QDateTime& digitized);
96+ void updateThumbnail(QImage image);
97
98 bool save() const;
99
100
101=== modified file 'src/photo/photo-edit-thread.cpp'
102--- src/photo/photo-edit-thread.cpp 2013-07-26 15:43:53 +0000
103+++ src/photo/photo-edit-thread.cpp 2015-01-20 20:19:07 +0000
104@@ -143,8 +143,10 @@
105 image = image.transformed(metadata->orientationTransform().inverted());
106
107 bool saved = image.save(m_photo->file().filePath(), m_photo->fileFormat().toStdString().c_str(), 90);
108- if (saved && m_photo->fileFormatHasMetadata())
109+ if (saved && m_photo->fileFormatHasMetadata()) {
110+ metadata->updateThumbnail(image);
111 saved = metadata->save();
112+ }
113 if (!saved)
114 qWarning() << "Error saving edited" << m_photo->file().filePath();
115

Subscribers

People subscribed via source and target branches

to all changes: