[Digikam-devel] [Bug 151552] Album and Imageeditor cache problems

Gilles Caulier caulier.gilles at gmail.com
Mon Feb 2 17:09:40 GMT 2009


http://bugs.kde.org/show_bug.cgi?id=151552





--- Comment #22 from Gilles Caulier <caulier gilles gmail com>  2009-02-02 18:09:37 ---
Andreas,

Some pointers for your investigations :

When digiKam image editor save image, code which render IPTC preview is given
below (cod eis not updated to LXR):

...
    // Get image Exif/IPTC data.
    DMetadata meta;
    meta.setExif(d->image.getExif());
    meta.setIptc(d->image.getIptc());
    meta.setXmp(d->image.getXmp());

    // Update IPTC preview.
    // NOTE: see B.K.O #130525. a JPEG segment is limited to 64K. If the IPTC
byte array is
    // bigger than 64K during of image preview tag size, the target JPEG image
will be
    // broken. Note that IPTC image preview tag is limited to 256K!!!
    // There is no limitation with TIFF and PNG about IPTC byte array size.

    // Before to update IPTC preview, we remove it.
    meta.removeIptcTag("Iptc.Application2.Preview");
    meta.removeIptcTag("Iptc.Application2.PreviewFormat");
    meta.removeIptcTag("Iptc.Application2.PreviewVersion");

    QSize previewSize = d->image.size();
    previewSize.scale(1280, 1024, Qt::KeepAspectRatio);
    QImage preview;
    // Ensure that preview is not upscaled
    if (previewSize.width() >= (int)d->image.width())
        preview = d->image.copyQImage();
    else
        preview = d->image.smoothScale(previewSize.width(),
previewSize.height(), Qt::IgnoreAspectRatio).copyQImage();

    // With JPEG file, we don't store IPTC preview.
    // NOTE: only store preview if pixel number is at least two times bigger
    if (/* (2*(previewSize.width() * previewSize.height()) <
(int)(d->image.width() * d->image.height())) &&*/
        (mimeType.toUpper() != QString("JPG") && mimeType.toUpper() !=
QString("JPEG") &&
         mimeType.toUpper() != QString("JPE"))
       )
    {
        // Non JPEG file, we update IPTC preview
        meta.setImagePreview(preview);
    }

    // Update Exif thumbnail.
    QImage thumb = preview.scaled(160, 120, Qt::KeepAspectRatio,
Qt::SmoothTransformation);
    meta.setExifThumbnail(thumb);

    // Update Exif Image dimensions.
    meta.setImageDimensions(d->image.size());

    // Update Exif Document Name tag with the original file name.
    meta.setExifTagString("Exif.Image.DocumentName", getImageFileName());

    // Update Exif Orientation tag if necessary.
    if( setExifOrientationTag )
        meta.setImageOrientation(DMetadata::ORIENTATION_NORMAL);

    // Store new Exif/IPTC/XMP data into image.
    d->image.setExif(meta.getExif());
    d->image.setIptc(meta.getIptc());
    d->image.setXmp(meta.getXmp());
...
DMetadata is a devirated class of libkexiv2. It include some digiKam internal
methods not shared with the rest of KDE. 

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dmetadata/dmetadata.h

d->image is an instance of DImg container used to store image data + image
metadata. 

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/dimg.h

We clear Iptc preview tags, and render preview as reduced image. This one is
passed to DMetadata container. Unforget here that we save PNG image.

http://lxr.kde.org/source/KDE/kdegraphics/libs/libkexiv2/libkexiv2/kexiv2image.cpp#841

After that, we update IPTC metadata to DImg instance, and we can start to save
really the image to PNG file. In this case, DIMG call a dedicated image writter
which use libpng :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/loaders/pngloader.cpp#556

In this code, you will see similar code than Exiv2 to make metadata PNG chunks.
In fact i must to update this image writter to use libpng to save metadata if
Exiv2 < 0.18 else Exiv2 as well. But here this is not the problem i think.

Gilles


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Digikam-devel mailing list