Author Topic: xml/opf to iptc  (Read 7461 times)

arnauld

  • Newbie
  • *
  • Posts: 3
xml/opf to iptc
« on: May 24, 2014, 05:23:52 AM »
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
« Last Edit: May 24, 2014, 05:37:12 AM by arnauld »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #1 on: May 24, 2014, 05:56:26 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

arnauld

  • Newbie
  • *
  • Posts: 3
Re: xml/opf to iptc
« Reply #2 on: May 26, 2014, 05:32:51 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #3 on: May 26, 2014, 07:45:56 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

arnauld

  • Newbie
  • *
  • Posts: 3
Re: xml/opf to iptc
« Reply #4 on: May 28, 2014, 04:20:53 PM »
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

Code: [Select]
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #5 on: May 28, 2014, 07:59:18 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

  • Newbie
  • *
  • Posts: 7
Re: xml/opf to iptc
« Reply #6 on: June 08, 2014, 07:12:42 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #7 on: June 09, 2014, 07:14:01 AM »
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 (phil at owl.phy.queensu.ca)

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

esoxlucius2004

  • Newbie
  • *
  • Posts: 7
Re: xml/opf to iptc
« Reply #8 on: June 09, 2014, 07:25:24 AM »
I just sent the message  :)
thank you.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #9 on: June 09, 2014, 08:03:32 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

  • Newbie
  • *
  • Posts: 7
Re: xml/opf to iptc
« Reply #10 on: June 09, 2014, 10:15:39 AM »
"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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #11 on: June 09, 2014, 10:26:11 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

  • Newbie
  • *
  • Posts: 7
Re: xml/opf to iptc
« Reply #12 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

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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: xml/opf to iptc
« Reply #13 on: June 09, 2014, 10:51:30 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

Quote
If 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esoxlucius2004

  • Newbie
  • *
  • Posts: 7
Re: xml/opf to iptc
« Reply #14 on: June 09, 2014, 11:51:01 AM »
Thank you for your good advice.
It works !