Skip to content

IPTC fixes #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MetadataExtractor/Formats/Iptc/IptcDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public sealed class IptcDirectory : Directory

private static readonly Dictionary<int, string> _tagNameMap = new()
{
{ TagEnvelopeRecordVersion, "Enveloped Record Version" },
{ TagEnvelopeRecordVersion, "Envelope Record Version" },
{ TagDestination, "Destination" },
{ TagFileFormat, "File Format" },
{ TagFileVersion, "File Version" },
Expand Down
7 changes: 3 additions & 4 deletions MetadataExtractor/Formats/Iptc/IptcReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public sealed class IptcReader : IJpegSegmentMetadataReader

internal const byte IptcMarkerByte = 0x1c;

ICollection<JpegSegmentType> IJpegSegmentMetadataReader.SegmentTypes { get; } = new[] { JpegSegmentType.AppD };
ICollection<JpegSegmentType> IJpegSegmentMetadataReader.SegmentTypes { get; } = [JpegSegmentType.AppD];

public IEnumerable<Directory> ReadJpegSegments(IEnumerable<JpegSegment> segments)
{
// Ensure data starts with the IPTC marker byte
return segments
.Where(segment => segment.Bytes.Length != 0 && segment.Bytes[0] == IptcMarkerByte)
.Select(segment => (Directory)Extract(new SequentialByteArrayReader(segment.Bytes), segment.Bytes.Length));
.Select(segment => Extract(new SequentialByteArrayReader(segment.Bytes), segment.Bytes.Length));
}

/// <summary>Reads IPTC values and returns them in an <see cref="IptcDirectory"/>.</summary>
Expand Down Expand Up @@ -166,7 +166,6 @@ private static void ProcessTag(SequentialReader reader, Directory directory, int
if (tagByteCount == 2)
{
var shortValue = reader.GetUInt16();
reader.Skip(tagByteCount - 2);
directory.Set(tagIdentifier, shortValue);
return;
}
Expand Down Expand Up @@ -208,7 +207,7 @@ private static void ProcessTag(SequentialReader reader, Directory directory, int

if (directory.ContainsTag(tagIdentifier))
{
// this fancy string[] business avoids using an ArrayList for performance reasons
// We already have a value for this tag. Append this value to any prior value(s).
var oldStrings = directory.GetStringValueArray(tagIdentifier);

StringValue[] newStrings;
Expand Down