Bug 272175 - picture orientation is "forgotten" in viewer and light table when using xmp sidecar [patch]
Summary: picture orientation is "forgotten" in viewer and light table when using xmp s...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Unclassified
Component: Metadata-Sidecar (show other bugs)
Version: 2.0.0
Platform: Ubuntu Packages Linux
: NOR normal with 20 votes (vote)
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-01 19:19 UTC by Ilia K.
Modified: 2017-08-11 14:11 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.0.0


Attachments
screenshot of digikam settings->meta data (66.10 KB, image/png)
2011-05-01 19:19 UTC, Ilia K.
Details
If sidecar exists, still read size, mimetype, comments, exif, and iptc from original image (2.71 KB, patch)
2011-07-09 22:36 UTC, Leif Huhn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ilia K. 2011-05-01 19:19:55 UTC
Created attachment 59510 [details]
screenshot of digikam settings->meta data

Version:           2.0.0 (using KDE 4.6.2) 
OS:                Linux

I'm using digikam 2.0 beta4 from philip5 PPA for Kubuntu 10.10.
Digikam is set to use sidecar XMP files (read and "write to XMP sidecar only"),
"Embedded preview loads full-sized images" is option unset.

When I add raw image (NEF) in portrait orientation to an album it's displayed correctly as long as metadata isn't edited (XMP sidecar doesn't exist). When I do any action which creates XMP sidecar I get:
- album view and image editor display file in correct orientation (portrait)
- embedded viewer displays portrait orientation in thumb bar, but (incorrect) landscape orientation in the main window
- light table displays file incorrectly

If I subsequently quit digikam, remove sidecar and start digikam it displays image correctly everywhere again.

Reproducible: Didn't try
Comment 1 caulier.gilles 2011-05-01 20:09:16 UTC
Can you give me the image + the sidecar file to test in local ?

Thanks in advance

Gilles Caulier
Comment 2 Ilia K. 2011-05-04 03:39:32 UTC
Ok, here is a link to tarball which contains raw (NEF) and XMP sidecar:
https://rapidshare.com/files/460492304/orientation_test.tar.gz

Another news, after removing a database and restoring all the metadata from images & XMP sidecars, album view displays now incorrect orientation too, so image editor is the only one displaying image correctly.
Comment 3 Leif Huhn 2011-07-09 21:41:04 UTC
I'm having the same problem.  This code from extra/libkexiv2/libkexiv2/kexiv2.cpp
 is related:

        // If XMP sidecar exist and if we want manage it, parse it instead the image.
        if (d->useXMPSidecar4Reading)
        {
            QString xmpSidecarPath = sidecarFilePathForFile(filePath);
            QFileInfo xmpSidecarFileInfo(xmpSidecarPath);

            if (xmpSidecarFileInfo.exists() && xmpSidecarFileInfo.isReadable())
            {
                // TODO: We should rather read both image and sidecar metadata
                // and merge the two, with sidecar taking precedence
                image = Exiv2::ImageFactory::open((const char*)
                        (QFile::encodeName(xmpSidecarPath)));
            }
        }

We're not storing the orientation in XMP at all, so unless we merge the data, we will have no orientation data.
Comment 4 Leif Huhn 2011-07-09 22:36:26 UTC
Created attachment 61736 [details]
If sidecar exists, still read size, mimetype, comments, exif, and iptc from original image

This patch causes DigiKam to read most of the metadata from the original file even if there is a sidecar.  It ignores the XMP data from the image itself when there is a sidecar.

This fixes the rotation problem.

This patch is meant to be applied on top of kde-bug-275311-rev2.diff from the other bug.  This patch rearranges lines that were edited from that patch, so if I generated a diff against 2.0.0-rc, then you could not cleanly apply both.
Comment 5 caulier.gilles 2011-07-10 06:51:45 UTC
Leif,

Thanks again to review XMP handling code. I will review it Monday morning. I don't have my computer to test here, i'm not at home/office.

Gilles Caulier
Comment 6 caulier.gilles 2011-07-11 09:03:16 UTC
Git commit 895fa43e61034daae00e70525d72482beeff1ca2 by Gilles Caulier.
Committed on 11/07/2011 at 10:58.
Pushed by cgilles into branch 'master'.

apply patch #61734 and #61736 from Leif Huhn to manage XMP sidecar and symbolic links properlly
- If sidecar exists, still read size, mimetype, comments, exif, and iptc from original image.
- Only follow the symlink when writing to the image file.
CCBUGS: 275311
CCBUGS: 272175

M  +83   -49   libkexiv2/kexiv2.cpp     

http://commits.kde.org/libkexiv2/895fa43e61034daae00e70525d72482beeff1ca2
Comment 7 Marcel Wiesweg 2011-07-11 16:33:52 UTC
Is there any support in exiv2 to "merge" metadata from sidecar and from original image?
Comment 8 Andreas Huggel 2011-07-12 06:10:35 UTC
(In reply to comment #7)
> Is there any support in exiv2 to "merge" metadata from sidecar and from
> original image?

Exiv2 has conversions to copy or move metadata of one kind to another: http://www.exiv2.org/doc/convert_8hpp.html
There is no support to merge two metadata containers of the same kind.

Andreas