Extracting ITPC data from JPG
flemingm opened this issue · comments
Using MediaExtractor v2.4.2
And console application for dotNet Code v3.1
Using extracted sample code from:
https://github.com/drewnoakes/metadata-extractor-dotnet/tree/master/MetadataExtractor.Samples
The JpegMetadataReader correctly read the metadata, but IJpegSegmentMetadataReader[] using new IptcReader() fails to find ITPC data (code shown below).
File I am using to test is::
`
Using JpegMetadataReader
[JPEG] Compression Type - Baseline
[JPEG] Data Precision - 8 bits
[JPEG] Image Height - 500 pixels
[JPEG] Image Width - 1000 pixels
...
[JPEG] Component 3 - Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert
[Exif IFD0] Image Description - The description aka caption (ref2019.1)
[Exif IFD0] X Resolution - 72 dots per inch
[Exif IFD0] Y Resolution - 72 dots per inch
[Exif IFD0] Resolution Unit - Inch
[Exif IFD0] Artist - Creator1 (ref2019.1)
[Exif IFD0] YCbCr Positioning - Center of pixel array
[Exif IFD0] Copyright - Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)
[XMP] XMP Value Count - 246
[IPTC] Object Attribute Reference - A Genre (ref2019.1)
[IPTC] Object Name - The Title (ref2019.1)
[IPTC] Subject Reference - IPTC:1ref2019.1 IPTC:2ref2019.1 IPTC:3ref2019.1
[IPTC] Keywords - Keyword1ref2019.1;Keyword2ref2019.1;Keyword3ref2019.1
[IPTC] Special Instructions - An Instruction (ref2019.1)
[IPTC] Date Created - 2019:10:16
[IPTC] Time Created - 19:01:00+0000
[IPTC] By-line - Creator1 (ref2019.1)
[IPTC] By-line Title - Creator's Job Title (ref2019.1)
[IPTC] City - City (Core) (ref2019.1)
[IPTC] Sub-location - Sublocation (Core) (ref2019.1)
[IPTC] Province/State - Province/State (Core) (ref2019.1
[IPTC] Country/Primary Location Code - R19
[IPTC] Country/Primary Location Name - Country (Core) (ref2019.1)
[IPTC] Original Transmission Reference - Job Id (ref2019.1)
[IPTC] Headline - The Headline (ref2019.1)
[IPTC] Credit - Credit Line (ref2019.1)
[IPTC] Source - Source (ref2019.1)
[IPTC] Copyright Notice - Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)
[IPTC] Caption/Abstract - The description aka caption (ref2019.1)
[IPTC] Caption Writer/Editor - Description Writer (ref2019.1)
[IPTC] Application Record Version - 4
[Adobe JPEG] DCT Encode Version - 25600
..
[Adobe JPEG] Color Transform - YCbCr
[Huffman] Number of Tables - 4 Huffman tables
[File] File Name - IPTC-PhotometadataRef-Std2019.1.jpg
[File] File Size - 128691 bytes
[File] File Modified Date - Fri May 29 22:34:33 -04:00 2020
-- End -- SCENARIO 2: SPECIFIC FILE TYPE
`
// APPROACH 3: SPECIFIC METADATA TYPE
//
// If you only wish to read a subset of the supported metadata types, you can do this by
// passing the set of readers to use.
//
try
{
// Handle only Exif and IPTC from JPEG
IJpegSegmentMetadataReader[] readers = new IJpegSegmentMetadataReader[] { new ExifReader(), new IptcReader() };
IJpegSegmentMetadataReader[] readersIPTC = new IJpegSegmentMetadataReader[] { new IptcReader() };
var directories = JpegMetadataReader.ReadMetadata(filePath, `readers);`
Print(directories, "\nUsing JpegMetadataReader for Exif and IPTC only ----");
var directoriesITPC = JpegMetadataReader.ReadMetadata(filePath, `readersIPTC);`
Print(directoriesITPC, "\nUsing JpegMetadataReader for IPTC only ----");
}
catch (JpegProcessingException e)
{
PrintError(e);
}
catch (IOException e)
{
PrintError(e);
}
`
Produces the following -- with not ITPC Data.
`
Using JpegMetadataReader for Exif and IPTC only ----
[Exif IFD0] Image Description - The description aka caption (ref2019.1)
[Exif IFD0] X Resolution - 72 dots per inch
[Exif IFD0] Y Resolution - 72 dots per inch
[Exif IFD0] Resolution Unit - Inch
[Exif IFD0] Artist - Creator1 (ref2019.1)
[Exif IFD0] YCbCr Positioning - Center of pixel array
[Exif IFD0] Copyright - Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)
[File] File Name - IPTC-PhotometadataRef-Std2019.1.jpg
[File] File Size - 128691 bytes
[File] File Modified Date - Fri May 29 22:34:33 -04:00 2020
Using JpegMetadataReader for IPTC only ----
[File] File Name - IPTC-PhotometadataRef-Std2019.1.jpg
[File] File Size - 128691 bytes
`
That image has IPTC data buried within the Photoshop segment. To get at it, you'll want to include MetadataExtractor.Formats.Photoshop.PhotoshopReader
as an IJpegSegmentMetadataReader
.
Thank you.