Skip to content

Commit 81cac99

Browse files
authored
Merge pull request #299 from kwhopper/iptc-photoshop
test "IPTC" profile type
2 parents a2fcf31 + 6018a9d commit 81cac99

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

MetadataExtractor/Formats/Png/PngMetadataReader.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,18 @@ IEnumerable<Directory> ProcessTextChunk(string keyword, byte[] textBytes)
410410
{
411411
if (TryProcessRawProfile(out int byteCount))
412412
{
413-
yield return new IptcReader().Extract(new SequentialByteArrayReader(textBytes), byteCount);
413+
// From ExifTool:
414+
// this is unfortunate, but the "IPTC" profile may be stored as either
415+
// IPTC IIM or a Photoshop IRB resource, so we must test for this.
416+
// Check if the first byte matches IptcReader.IptcMarkerByte (0x1c)
417+
if (byteCount > 0 && textBytes[0] == 0x1c)
418+
yield return new IptcReader().Extract(new SequentialByteArrayReader(textBytes), byteCount);
419+
else
420+
{
421+
foreach (var psDirectory in new Photoshop.PhotoshopReader().Extract(new SequentialByteArrayReader(textBytes), byteCount))
422+
yield return psDirectory;
423+
424+
}
414425
}
415426
else
416427
{

0 commit comments

Comments
 (0)