janfri / mini_exiftool

This library is a wrapper for the Exiftool command-line application (https://exiftool.org) written by Phil Harvey. It provides the full power of Exiftool to Ruby: reading and writing of EXIF-data, IPTC-data and XMP-data. Branch master is for actual development and branch compatibility-version is for compatibility with Ruby 1.8 and exiftool versions prior 7.65.
GNU Lesser General Public License v2.1
213 stars 52 forks source link

IPTC Data types, "seem" to work but don't get persisted. #41

Closed Jaciones closed 3 years ago

Jaciones commented 3 years ago

MiniExifTool seems to validate proper IPTC data structure, and then accepts ONLY the properly formatted structure, but then never persists the validated structure. Here is an example where 'sample.jpg" can be ANY ".jpg" file.

photo = MiniExiftool.new 'sample.jpg'
photo["CopyrightOwner"] = "jason"
 => "jason"
photo.save
photo.errors
 => {"copyrightowner"=>"Warning: Improperly formed structure for XMP-plus:CopyrightOwner"}

So far, this is absolutely correct. As per the IPTC spec, CopyrightOwner requires 2 children nodes, "CopyrightOwnerID" && "CopyrightOwnerID".

So if we add those:

photo["CopyrightOwner"]='{"CopyrightOwnerID" : "23412412","CopyrightOwnerName" : "jason"}}'
photo.save
 => true

But the NEITHER the output file, nor the existing photo object have those values saved:

photo["CopyrightOwner"]
 => ""

NOR

exiftool sample.jpg | grep "Copyright Owner"
Copyright Owner        :     

Expected Result: "Copyright Owner" would be persisted in the EXIF data as per IPTC spec.

janfri commented 3 years ago

It's much simpler:

photo = MiniExiftool.new('sample.jpg')
photo.copyright_owner_name = 'jason'
photo.copyright_owner_id = '23412412'
photo.save
janfri commented 3 years ago

@Jaciones let me know if you need further help.