patch: write EXIF/XMP to psd
Added by Michael Ulbrich over 12 years ago
Hi Andreas, all,
as promised here are patches against rev. 1750 repository files src/psdimage.cpp and src/psdimage.hpp. Now, writing IPTC / EXIF / XMP metadata to psd files should be fully supported.
I did not use the provided method stubs like
void PsdImage::setExifData(const ExifData& /*exifData*/)
but instead created a set of new methods
uint32_t PsdImage::_setExifData(const ExifData& exifData, BasicIo& out) etc.
This may still need improvements to better fit the given class / method structure.
Another point, which I did not fully understand, is why does writeXmpFromPacket() return false, even if XMP data has not been manipulated and the original packet could have been written back to the image unaltered. Instead a new XMP packet is generated every time any metadata is written where the x:xmptk attribute is updated to reflect Exiv2's version of xmptk. Am I missing something here?
The only case where I saw writeXmpFromPacket() return true was when XMP data was deleted completely and an empty XMP packet was "written" back to the image.
Please let me know, if I can be of any further help.
Best regards ... Michael
| psdimage.cpp.patch (15.5 KB) psdimage.cpp.patch | |||
| psdimage.hpp.patch (572 Bytes) psdimage.hpp.patch |
Replies (3)
RE: patch: write EXIF/XMP to psd - Added by Andreas Huggel over 12 years ago
Hi Michael,
Great, thanks for your patch! Just some initial comments, I haven't had time to look at the code in detail yet.
uint32_t PsdImage::_setExifData(const ExifData& exifData, BasicIo& out) etc.
What's the reason for this choice?
why does writeXmpFromPacket() return false, even if XMP data has not been manipulated
This functionality does not really fit, I'm actually considering to drop it (see #613). The original idea was to provide some minimal XMP functionality even if XMP support is not compiled. It is meant to be a switch: if you set a complete XMP packet, then that packet will be written back unchanged too. I can see where you're coming from, but that's not what the code is supposed to do. (And I can't think of a simple way to figure out whether the metadata has been manipulated right now.)
Finally, although I'm asking late once more: are you ok to assign the copyright of your code to me? I require this because I dual-license the library. Of course your name will remain an author of the modified files.
Regards,
Andreas
RE: patch: write EXIF/XMP to psd - Added by Michael Ulbrich over 12 years ago
Hi Andreas!
uint32_t PsdImage::_setExifData(const ExifData& exifData, BasicIo& out) etc.
What's the reason for this choice?
Well, the PSD image header contains a field giving the total length of all following resource blocks for a particular image. When writing out PSD Metadata the total length value is initially set to the old value of the unmodified image. Then individual resource blocks are written out and their length is accumulated in newResLength, which finally updates the old value for total length and possibly reflects the modifications to EXIF/IPTC/XMP. The _set* methods return the length of the corresponding resource block, e.g.
newResLength += setXmpData(xmpData, outIo);
The other change to the existing prototype - added parameter BasicIo& out - happened due to the fact that I do use the BasicIo object from within the _set* methods and I found no other way to make it accessible than to pass a reference to it.
Again, no problem with the copyright here.
Regards ... Michael
RE: patch: write EXIF/XMP to psd - Added by Andreas Huggel over 12 years ago
It's finally checked-in, with minor changes (r1774). Thanks Michael!