Bug 275122 - Rotating a TIFF file wipes out its metadata
Summary: Rotating a TIFF file wipes out its metadata
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-TIFF (show other bugs)
Version: 2.0.0
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 16:06 UTC by Guillaume Paumier
Modified: 2017-07-30 16:00 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.6.0
Sentry Crash Report:


Attachments
exiv2 -pa output for the test (rotated) file (205.58 KB, application/octet-stream)
2011-06-07 16:06 UTC, Guillaume Paumier
Details
exiv2 -pa output for the reference (prior to rotation) file (22.99 KB, application/octet-stream)
2011-06-07 16:07 UTC, Guillaume Paumier
Details
Batch Queue Manager Rotate tool in action (222.43 KB, image/png)
2011-06-08 06:48 UTC, caulier.gilles
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Paumier 2011-06-07 16:06:56 UTC
Created attachment 60750 [details]
exiv2 -pa output for the test (rotated) file

Version:           2.0.0 (using KDE 4.6.2) 
OS:                Linux

Rotating a TIFF file with metadata in digikam wipes out most of its metadata.

The attachments text files show the output of "exiv2 -pa" on two identical files, before ("reference") and after ("test") the rotation.

The reference and test files are also available:
http://dl.dropbox.com/u/17707983/rotate-reference.tif
http://dl.dropbox.com/u/17707983/rotate-test.tif

This issue is particularly problematic, because it causes data loss; relevant metadata like speed, aperture, etc. of a photograph are lost forever.

(One could attempt to restore some of the metadata using the values saved in the database, unfortunately metadata can't be written to TIFF files; see bug 271757)

Reproducible: Always

Steps to Reproduce:
* Open a TIFF file with metadata (e.g. the attached reference photograph)
* look at the metadata, e.g. using exiv2 -pa <filename.tif>
* rotate the picture in digikam
* look at the metadata again
Comment 1 Guillaume Paumier 2011-06-07 16:07:46 UTC
Created attachment 60751 [details]
exiv2 -pa output for the reference (prior to rotation) file
Comment 2 caulier.gilles 2011-06-07 19:27:42 UTC
How do you perform rotation ? in editor, or using album icon view (through kipi-plugins)

Gilles Caulier
Comment 3 caulier.gilles 2011-06-07 19:29:46 UTC
If you use editor, rotation is performed on touch only image data. Metadata are transfered to target image using Exiv2.

Andreas,

It can be an libexiv2 issue ?

Gilles Caulier
Comment 4 Guillaume Paumier 2011-06-07 20:27:09 UTC
The problem appears (at least) when rotating using the icon in the album view.
Comment 5 caulier.gilles 2011-06-07 21:01:23 UTC
From iconview, kipi-plugins is used, and workflow is different.

Image is rotated using libtiff, and after metadata after updated using Exiv2.

Note : can ypu confirm that rotating through Image editor or Batch Queue Manager in digiKam do not lost metadata ?

Gilles Caulier
Comment 6 Guillaume Paumier 2011-06-07 21:41:07 UTC
(In reply to comment #5)
> From iconview, kipi-plugins is used, and workflow is different.
> 
> Image is rotated using libtiff, and after metadata after updated using Exiv2.

Then maybe this is caused by bug 271757.

> Note : can you confirm that rotating through Image editor or Batch Queue
> Manager in digiKam do not lost metadata ?

As far as my testing can tell:
* Rotating through the image editor seems to preserve the metadata;
* Unless I'm doing something wrong, rotating through the batch queue manager doesn't seem to rotate at all (!).
Comment 7 caulier.gilles 2011-06-08 06:48:14 UTC
Created attachment 60772 [details]
Batch Queue Manager Rotate tool in action
Comment 8 caulier.gilles 2011-07-06 11:26:28 UTC
We need feedback using a recent version. 2.0.0 RC is out, please test...

Thanks in advance

Gilles Caulier
Comment 9 Marcel Wiesweg 2011-07-11 17:03:43 UTC
I can confirm this as a kipi-plugins problem. 
Took a random metadata, used icons to rotate, metadata is gone.
Command line output:

digikam(5413)/KIPI (general) KIPIJPEGLossLessPlugin::ImageRotate::rotateImageMagick: ImageMagick Command line:  ("convert", "-rotate", "90", 
"/media/fotos/Digikam Sample/TIFF/01-TIF - 8bits - RGB- NONE_1.tiff[0]", "/tmp/kde-marcel/digikamTJ5413kipiplugin-rotate.tiff")
convert: /media/fotos/Digikam Sample/TIFF/01-TIF - 8bits - RGB- NONE_1.tiff: invalid TIFF directory; tags are not sorted in ascending order. 
`TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/704.
convert: /media/fotos/Digikam Sample/TIFF/01-TIF - 8bits - RGB- NONE_1.tiff: unknown field with tag 11 (0xb) encountered. `TIFFReadDirectory' @ 
warning/tiff.c/TIFFWarnings/704.
convert: /media/fotos/Digikam Sample/TIFF/01-TIF - 8bits - RGB- NONE_1.tiff: unknown field with tag 18246 (0x4746) encountered. `TIFFReadDirectory' 
@ warning/tiff.c/TIFFWarnings/704.
convert: /media/fotos/Digikam Sample/TIFF/01-TIF - 8bits - RGB- NONE_1.tiff: unknown field with tag 18249 (0x4749) encountered. `TIFFReadDirectory' 
@ warning/tiff.c/TIFFWarnings/704.
digikam(5413)/KEXIV2 KExiv2Iface::KExiv2::setImageOrientation: Exif.Image.Orientation tag set to:  1
digikam(5413)/KEXIV2 KExiv2Iface::KExiv2::setImagePreview: JPEG image preview size: ( 682  x  1024 ) pixels -  83729  bytes
digikam(5413)/KIPI (general) KIPIJPEGLossLessPlugin::Utils::updateMetadataImageMagick: ImageMagick Command line:  ("mogrify", "-profile", 
"/tmp/kde-marcel/digikamhX5413kipipluginsexif.app1", "-profile", "/tmp/kde-marcel/digikamSL5413kipipluginsiptc.8bim", "-profile", "/tmp/kde-
marcel/digikamnn5413kipipluginsxmp.xmp", "/tmp/kde-marcel/digikamTJ5413kipiplugin-rotate.tiff[0]")

Looks as if we used temp files with stored metadata 
and then mogrify -profile to rewrite the metadata?
Comment 10 caulier.gilles 2011-12-22 15:44:27 UTC
Guillaume,

This file still valid using kipi-plugins 2.4 ?

Gilles Caulier
Comment 11 caulier.gilles 2012-01-25 10:04:03 UTC
Guillaume,

With next digiKam 2.6.0 (current implementation from Git/Master), we don't use JPEGLossLess kipi plugin to rotate or flip image. A dedicated implementation is used from digiKam core to process transformation.

Can you reproduce the problem ?

Gilles Caulier
Comment 12 Guillaume Paumier 2012-01-28 15:16:05 UTC
I confirm that afaict the problem has disappeared with the current implementation in git/master. Rotating using the album icons now preserves the metadata in TIFF files.