diff --git a/src/common/exif.cc b/src/common/exif.cc index b18d4869879c..b2a676359dd9 100644 --- a/src/common/exif.cc +++ b/src/common/exif.cc @@ -1057,14 +1057,16 @@ int dt_exif_write_blob(uint8_t *blob, uint32_t size, const char *path, const int Exiv2::ExifData blobExifData; Exiv2::ExifParser::decode(blobExifData, blob + 6, size); Exiv2::ExifData::const_iterator end = blobExifData.end(); + Exiv2::ExifData::iterator it; for(Exiv2::ExifData::const_iterator i = blobExifData.begin(); i != end; ++i) { + // add() does not override! we need to delete existing key first. Exiv2::ExifKey key(i->key()); - if(imgExifData.findKey(key) == imgExifData.end()) - imgExifData.add(Exiv2::ExifKey(i->key()), &i->value()); + if((it = imgExifData.findKey(key)) != imgExifData.end()) imgExifData.erase(it); + + imgExifData.add(Exiv2::ExifKey(i->key()), &i->value()); } // Remove thumbnail - Exiv2::ExifData::iterator it; if((it = imgExifData.findKey(Exiv2::ExifKey("Exif.Thumbnail.Compression"))) != imgExifData.end()) imgExifData.erase(it); if((it = imgExifData.findKey(Exiv2::ExifKey("Exif.Thumbnail.XResolution"))) != imgExifData.end()) @@ -1114,8 +1116,6 @@ int dt_exif_read_blob(uint8_t *buf, const char *path, const int imgid, const int assert(image.get() != 0); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); - // needs to be reset, even in dng mode, as the buffers are flipped during raw import - exifData["Exif.Image.Orientation"] = uint16_t(1); // get rid of thumbnails Exiv2::ExifThumb(exifData).erase(); @@ -1154,6 +1154,8 @@ int dt_exif_read_blob(uint8_t *buf, const char *path, const int imgid, const int { /* Delete various MakerNote fields only applicable to the raw file */ + exifData["Exif.Image.Orientation"] = uint16_t(1); + // Canon color space info if((pos = exifData.findKey(Exiv2::ExifKey("Exif.Canon.ColorSpace"))) != exifData.end()) exifData.erase(pos); diff --git a/src/common/imageio.c b/src/common/imageio.c index 3efc67010f64..cef222585fe1 100644 --- a/src/common/imageio.c +++ b/src/common/imageio.c @@ -663,13 +663,16 @@ int dt_imageio_export_with_flags(const uint32_t imgid, const char *filename, buf.pre_monochrome_demosaiced); dt_dev_pixelpipe_create_nodes(&pipe, &dev); dt_dev_pixelpipe_synch_all(&pipe, &dev); - dt_dev_pixelpipe_get_dimensions(&pipe, &dev, pipe.iwidth, pipe.iheight, &pipe.processed_width, - &pipe.processed_height); + if(filter) { if(!strncmp(filter, "pre:", 4)) dt_dev_pixelpipe_disable_after(&pipe, filter + 4); if(!strncmp(filter, "post:", 5)) dt_dev_pixelpipe_disable_before(&pipe, filter + 5); } + + dt_dev_pixelpipe_get_dimensions(&pipe, &dev, pipe.iwidth, pipe.iheight, &pipe.processed_width, + &pipe.processed_height); + dt_show_times(&start, "[export] creating pixelpipe", NULL); // find output color profile for this image: