I have made the following changes intended for :
  CE:MW:Shared / nemo-qml-plugins

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.pub.meego.com//request/show/5565

Thank You,
hmallat

[This message was auto-generated]

---

Request # 5565:

Messages from BOSS:

State: review at 2012-08-13T10:18:36 by bossbot

Reviews:
       accepted by bossbot : Prechecks succeeded.
       new for CE-maintainers : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:hmallat:branches:CE:MW:Shared / nemo-qml-plugins -> CE:MW:Shared 
/ nemo-qml-plugins
  
changes files:
--------------
--- nemo-qml-plugins.changes
+++ nemo-qml-plugins.changes
@@ -0,0 +1,3 @@
+* Sun Aug 12 2012 Hannu Mallat <[email protected]> - 0.0.4
+- Fixes NEMO#150: JPEG thumbnail orientation according to EXIF data
+

new:
----
  0001-Read-orientation-data-from-JPEG-EXIF.patch

spec files:
-----------
--- nemo-qml-plugins.spec
+++ nemo-qml-plugins.spec
@@ -16,6 +16,7 @@
 URL:        https://github.com/nemomobile/nemo-qml-plugins
 Source0:    %{name}-%{version}.tar.bz2
 Source100:  nemo-qml-plugins.yaml
+Patch0:     0001-Read-orientation-data-from-JPEG-EXIF.patch
 BuildRequires:  pkgconfig(QtCore) >= 4.7.0
 BuildRequires:  pkgconfig(QtDeclarative)
 BuildRequires:  pkgconfig(QtGui)
@@ -49,6 +50,8 @@
 %prep
 %setup -q -n %{name}
 
+# 0001-Read-orientation-data-from-JPEG-EXIF.patch
+%patch0 -p1
 # >> setup
 # << setup
 

other changes:
--------------

++++++ 0001-Read-orientation-data-from-JPEG-EXIF.patch (new)
--- 0001-Read-orientation-data-from-JPEG-EXIF.patch
+++ 0001-Read-orientation-data-from-JPEG-EXIF.patch
@@ -0,0 +1,578 @@
+From 15c557f2f5f384355e6c44aa99033a7acb29b51a Mon Sep 17 00:00:00 2001
+From: Hannu Mallat <[email protected]>
+Date: Sat, 4 Aug 2012 22:08:19 +0300
+Subject: [PATCH] Read orientation data from JPEG EXIF.
+
+---
+ thumbnailer/nemoimagemetadata.cpp     |  352 +++++++++++++++++++++++++++++++++
+ thumbnailer/nemoimagemetadata.h       |   78 ++++++++
+ thumbnailer/nemothumbnailprovider.cpp |   68 ++++++-
+ thumbnailer/thumbnailer.pro           |    6 +-
+ 4 files changed, 500 insertions(+), 4 deletions(-)
+ create mode 100644 thumbnailer/nemoimagemetadata.cpp
+ create mode 100644 thumbnailer/nemoimagemetadata.h
+
+diff --git a/thumbnailer/nemoimagemetadata.cpp 
b/thumbnailer/nemoimagemetadata.cpp
+new file mode 100644
+index 0000000..73923cd
+--- /dev/null
++++ b/thumbnailer/nemoimagemetadata.cpp
+@@ -0,0 +1,352 @@
++/*
++ * Copyright (C) 2012 Hannu Mallat <[email protected]>
++ *
++ * You may use this file under the terms of the BSD license as follows:
++ *
++ * "Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions are
++ * met:
++ *   * Redistributions of source code must retain the above copyright
++ *     notice, this list of conditions and the following disclaimer.
++ *   * Redistributions in binary form must reproduce the above copyright
++ *     notice, this list of conditions and the following disclaimer in
++ *     the documentation and/or other materials provided with the
++ *     distribution.
++ *   * Neither the name of Nemo Mobile nor the names of its contributors
++ *     may be used to endorse or promote products derived from this
++ *     software without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++ */
++
++#include "nemoimagemetadata.h"
++
++#include <QFile>
++#include <QString>
++#include <QtEndian>
++
++#define EXIF_ORIENTATION_TOP_LEFT 1
++#define EXIF_ORIENTATION_TOP_RIGHT 2
++#define EXIF_ORIENTATION_BOTTOM_RIGHT 3
++#define EXIF_ORIENTATION_BOTTOM_LEFT 4
++#define EXIF_ORIENTATION_LEFT_TOP 5
++#define EXIF_ORIENTATION_RIGHT_TOP 6
++#define EXIF_ORIENTATION_RIGHT_BOTTOM 7
++#define EXIF_ORIENTATION_LEFT_BOTTOM 8
++
++#ifdef HAS_LIBEXIF
++
++extern "C" {
++#include <libexif/exif-data.h>
++#include <libexif/exif-loader.h>
++}
++
++static void exifBrowseContent(ExifContent *c, void *p)
++{
++    if (c == 0 || p == 0)
++        return;
++
++    quint16 *o = static_cast<quint16 *>(p);
++    ExifIfd ifd = exif_content_get_ifd(c);
++    if (ifd == EXIF_IFD_0) {
++        ExifEntry *entry = exif_content_get_entry(c, EXIF_TAG_ORIENTATION);
++        if (entry != 0 &&
++          entry->data !=0 &&
++            entry->tag == EXIF_TAG_ORIENTATION &&
++            entry->format == EXIF_FORMAT_SHORT &&
++            entry->components == 1 &&
++            entry->size == 2) {
++            *o = exif_data_get_byte_order(entry->parent->parent) ==
++                    EXIF_BYTE_ORDER_MOTOROLA
++                    ? qFromBigEndian<quint16>(entry->data)
++                    : qFromLittleEndian<quint16>(entry->data);
++        }
++    }
++}
++
++static quint16 exifOrientation(const QString &filename)
++{
++    quint16 o = EXIF_ORIENTATION_TOP_LEFT;
++    ExifLoader *loader = 0;
++    ExifData *exif = 0;
++
++    loader = exif_loader_new();
++    if (loader == 0)
++        goto exit;
++
++    exif_loader_write_file(loader, QFile::encodeName(filename).constData());
++    exif = exif_loader_get_data(loader);
++    if (exif == 0)
++        goto exit;
++
++    exif_data_foreach_content(exif, exifBrowseContent, &o);
++    if (o < EXIF_ORIENTATION_TOP_LEFT || o > EXIF_ORIENTATION_LEFT_BOTTOM)
++        o = EXIF_ORIENTATION_TOP_LEFT;
++
++exit:
++    if (exif != 0)
++        exif_data_unref(exif);
++    if (loader != 0)
++        exif_loader_unref(loader);
++
++    return o;
++}
++
++#else // HAS_LIBEXIF
++
++#define EXIF_TIFF_LSB_MAGIC "Exif\x00\x00II\x2a\x00"
++#define EXIF_TIFF_MSB_MAGIC "Exif\x00\x00MM\x00\x2a"
++#define EXIF_TIFF_MAGIC_LEN 10
++
++#define TIFF_HEADER_LEN 8
++#define TIFF_IFD_ENTRY_LEN 12
++
++#define EXIF_IDENTIFIER_LEN 6
++
++#define EXIF_TYPE_SHORT 3
++
++#define EXIF_TAG_ORIENTATION 0x112
++
++/* Standalone markers without length information */
++#define JPEG_MARKER_TEM  0x01
++#define JPEG_MARKER_RST0 0xd0
++#define JPEG_MARKER_RST1 0xd1
++#define JPEG_MARKER_RST2 0xd2
++#define JPEG_MARKER_RST3 0xd3
++#define JPEG_MARKER_RST4 0xd4
++#define JPEG_MARKER_RST5 0xd5
++#define JPEG_MARKER_RST6 0xd6
++#define JPEG_MARKER_RST7 0xd7
++#define JPEG_MARKER_SOI  0xd8
++#define JPEG_MARKER_EOI  0xd9
++
++#define JPEG_MARKER_APP1 0xe1
++
++static uchar getMarker(QFile &f)
++{
++    /* CCITT T.81 Annex B: "All markers are assigned two-byte
++       codes: an XFF byte followed by a byte which is not equal
++       to 0 or XFF (see Table B.1). Any marker may optionally be
++       preceded by any number of fill bytes, which are bytes
++       assigned code XFF." */
++
++    char c;
++
++    if (f.getChar(&c) == false || c != -1)
++        return 0;
++
++    while (c == -1)
++        if (f.getChar(&c) == false)
++            return 0;
++
++    if (c == 0) /* Not a marker */
++        return 0;
++
++    return static_cast<uchar>(c);
++}
++
++static quint16 getMarkerLength(QFile &f)
++{
++    char buf[2];
++
++    if (f.read(buf, 2) != 2)
++        return 0;
++    return qFromBigEndian<quint16>(reinterpret_cast<uchar *>(buf));
++}
++
++static bool getExifData(QFile &f, QByteArray &data)
++{
++    uchar marker;
++    quint16 len;
++    qint64 skip;
++
++    f.seek(0);
++
++    marker = getMarker(f);
++    if (marker != JPEG_MARKER_SOI)
++        return false;
++    while (true) {
++        marker = getMarker(f);
(379 more lines skipped)

++++++ nemo-qml-plugins.yaml
--- nemo-qml-plugins.yaml
+++ nemo-qml-plugins.yaml
@@ -6,6 +6,8 @@
 Release: 1
 Sources:
     - "%{name}-%{version}.tar.bz2"
+Patches:
+    - 0001-Read-orientation-data-from-JPEG-EXIF.patch
 License: BSD
 URL: https://github.com/nemomobile/nemo-qml-plugins
 Configure: none



Reply via email to