-
Notifications
You must be signed in to change notification settings - Fork 1
add itext metadata support #491
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ public class PngMetadataExtractor | |
| SkipBytes(fs, 4); | ||
| break; | ||
| case "tEXt": | ||
| case "iTXt": | ||
| var keywordValuePair = await ReadTextualData(fs, chunkLength); | ||
| SkipBytes(fs, 4); // Move past the current chunk CRC | ||
| yield return keywordValuePair; | ||
|
Comment on lines
33
to
36
|
||
|
|
@@ -80,7 +81,7 @@ private async static Task<string> ReadChunkType(Stream stream) | |
| var nullIndex = dataString.IndexOf(NullTerminator); | ||
| return new ( | ||
| nullIndex > -1 ? dataString.Substring(0, nullIndex) : string.Empty, | ||
| nullIndex > -1 && nullIndex + 1 < length ? dataString.Substring(nullIndex + 1).TrimEnd(NullTerminator) : string.Empty | ||
| nullIndex > -1 && nullIndex + 1 < length ? dataString.Substring(nullIndex + 1).Trim(NullTerminator) : string.Empty | ||
| ); | ||
|
Comment on lines
85
to
90
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iTXtchunks do not have the same payload layout astEXt(they include compression flag/method + language tag + translated keyword + possibly zlib-compressed UTF-8 text). RoutingiTXtthroughReadTextualDatawill yield incorrect values (and can include binary bytes/garbage). Add a dedicatedReadInternationalTextualDataparser foriTXt(including optional zlib decompression) and call that from this switch case instead of reusing thetEXtlogic.