Main Menu

xml/opf to iptc

Started by arnauld, May 24, 2014, 05:23:52 AM

Previous topic - Next topic

arnauld

Hello

first, thanks for this tool exiftool.

I work with Epub files using Calibre http://en.wikipedia.org/wiki/Calibre_(software) and when I export, 3 files are created

-epub file
-the picture / the cover
-opf file = metadata

I d like to retrieve the infos #title/creator/date/description# from opf files//xml to write them in the iptc of the corresponding pictures.

Is it possible ?

Thanks for the reply

Arnauld

Phil Harvey

Hi Arnauld,

I've never seen an opf file, but my guess is that you would need to do some custom scripting to parse it.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

arnauld

hi Phil

here is one of my opf file, if you have time to have a look http://cjoint.com/?DEzv5RY96Xp

The data to retrieve as shown in the attached doc is

Quote<dc:title>
<dc:creator>
<dc:date>
<dc:description>

When you say I need to do some scripting to parse it, well, I have no idea of what kind of scripting you are talking about...

Arnauld

Phil Harvey

Hi Arnauld,

The OPF file is XML-based, so ExifTool will read it.  So the command you want is something like this:

exiftool -tagsfromfile NAME.opf "-description<PackageMetadataDescription" NAME.jpg

Here I have written the value to XMP:Description even though you said IPTC.  If you really want to write it to IPTC, use "Caption-Abstract" instead.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

arnauld

hi Phil

thanks for your reply and advice and exiftool. If anybody is interested, here is a link for the solution, the problem was solved with the advice you gave me

exiftool -codedcharacterset=utf8 -tagsfromfile Des_âmes_noires.opf "-Caption-Abstract<PackageMetadataDescription" Des_âmes_noires.jpg
exiftool -codedcharacterset=utf8 -tagsfromfile Des_âmes_noires.opf "-ObjectName<PackageMetadataTitle" Des_âmes_noires.jpg
exiftool -codedcharacterset=utf8 -tagsfromfile Des_âmes_noires.opf "-By-line<PackageMetadataCreator" Des_âmes_noires.jpg


from http://www.clubdeslecteurs.org/showthread.php?tid=15737

Phil Harvey

Arnauld,

Just a heads up:  ExifTool 9.63 will have the ability to read EPUB files, and will extract these values from the contained OPF file without the "PackageMetadata" prefix on the tag names.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

Hi Phil,

I can not retrieve the values ​​contained in the epub file
exiftool -codedcharacterset=utf8 -tagsfromfile Camilla_Lackberg_La_Sirene.epub "-Description" Camilla_Lackberg_La_Sirene.jpg

Warning: Unrecognized MIMEType - Camilla_Lackberg_La_Sirene.epub
Warning: No writable tags set from Camilla_Lackberg_La_Sirene.epub
    1 image files updated

What is the solution?

Thanks for the reply

Phil Harvey

Your EPUB is different from all my samples, and it appears that the MIME type embedded in the file is not "application/epub+zip" as expected.

If you can mail me the file, I will take a look (philharvey66 at gmail.com)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

I just sent the message  :)
thank you.

Phil Harvey

I got the file.  ExifTool 9.63 extracts the Description from this file without any problem.  I think you may be still using an old version of ExifTool.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

"exiftool-ver" command returns me well version 9.63.

exiftool -codedcharacterset=utf8 -tagsfromfile Camilla_Lackberg_La_Sirene.epub "-Creator" Camilla_Lackberg_La_Sirene.jpg
Warning: [minor] Error 3 placing :manifestItemHref in structure or list - Camilla_Lackberg_La_Sirene.epub
    1 image files updated

In exiftool GUI, XMP has been modified but not the IPTC format.
How to write the IPTC format from an Epub file ?

exiftool -g Camilla_lackberg_La_Sirene.jpg

---- ExifTool ----
ExifTool Version Number         : 9.63
---- File ----
File Name  : Camilla_Lackberg_La_Sirene.jpg
Directory: .
File Size  : 56 kB
File Modification Date/Time   : 2014:06:09 16:02:59+02:00
File Access Date/Time   : 2014:06:09 16:02:59+02:00
File Creation Date/Time    : 2014:06:09 16:02:59+02:00
File Permissions : rw-rw-rw-
File Type : JPEG
MIME Type: image/jpeg
Current IPTC Digest  : 2b3df19b0c67788262a0d0dced3b6d58
Image Width  : 600
Image Height  : 993
Encoding Process: Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components: 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
---- JFIF ----
JFIF Version   : 1.01
Resolution Unit : inches
X Resolution  : 105
Y Resolution  : 105
---- IPTC ----
Coded Character Set  : UTF8
Envelope Record Version  : 4
---- XMP ----
XMP Toolkit  : Image::ExifTool 9.63
Creator   : Camilla Lackberg






Phil Harvey

You can copy an source tag to any destination you want.  See the -tagsFromFile option in the application documentation for details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

Before the latest version, I used the following commands :

exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.opf "-Caption-Abstract<PackageMetadataDescription" Des_ames_noires.jpg
exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.opf "-ObjectName<PackageMetadataTitle" Des_ames_noires.jpg
exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.opf "-By-line<PackageMetadataCreator" Des_ames_noires.jpg

I can not understand that we could spent the OPF file with the new version that was able to read the tags directly from the epub file.

If I want to run commands on a folder, what command should I use?
exiftool-r-DIR?

Phil Harvey

Quote from: esoxlucius2004 on June 09, 2014, 10:39:56 AM
Before the latest version, I used the following commands :

exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.opf "-Caption-Abstract<PackageMetadataDescription" Des_ames_noires.jpg
exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.opf "-ObjectName<PackageMetadataTitle" Des_ames_noires.jpg
exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.opf "-By-line<PackageMetadataCreator" Des_ames_noires.jpg

Combining this into a single command, with the current version the command would be:

exiftool -codedcharacterset=utf8 -tagsfromfile Des_ames_noires.epub "-Caption-Abstract<Description" "-ObjectName<Title" "-By-line<Creator" Des_ames_noires.jpg

QuoteIf I want to run commands on a folder, what command should I use?
exiftool-r-DIR?

The above command would change to this:

exiftool -codedcharacterset=utf8 -tagsfromfile %d%f.epub "-Caption-Abstract<Description" "-ObjectName<Title" "-By-line<Creator" -r -ext jpg DIR

where DIR is the name of the directory containing the EPUB and same-named JPEG files.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

Thank you for your good advice.
It works !