-
-
Notifications
You must be signed in to change notification settings - Fork 890
[EXIF] Support UCS2 and 8-byte encoded string tags #1935
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
JimBobSquarePants
merged 38 commits into
SixLabors:master
from
IldarKhayrutdinov:exif-encoded-strings
Feb 3, 2022
Merged
Changes from 5 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e78190f
implement read&write encoded string tags
IldarKhayrutdinov 0082fd2
encoded string tags
IldarKhayrutdinov 83547db
update test
IldarKhayrutdinov d0dbb8e
add hashCode method
IldarKhayrutdinov c1ebf13
add missing docs
IldarKhayrutdinov 06e1d8b
Update src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs
IldarKhayrutdinov 53f85ac
build fixes
IldarKhayrutdinov aa2eba6
add test
IldarKhayrutdinov cb9d1b8
test fix
IldarKhayrutdinov d4fb48d
Merge remote-tracking branch 'upstream/master' into exif-encoded-strings
IldarKhayrutdinov 2e219ed
renaming, cosmetics
IldarKhayrutdinov f954a84
move EncodedStringCode enum into EncodedString class
IldarKhayrutdinov b510cfb
Merge remote-tracking branch 'upstream/master' into exif-encoded-strings
IldarKhayrutdinov c71b2aa
small refactory EncodedString methods
IldarKhayrutdinov cbb4514
Change data types of UCS-2 tags: byte[] -> string
IldarKhayrutdinov 5649128
correct reading UCS-2 encoded string tags
IldarKhayrutdinov 918db05
add missing file
IldarKhayrutdinov 14d7b60
support writing UCS-2 encoded string
IldarKhayrutdinov 1960c25
Merge remote-tracking branch 'upstream/master' into exif-encoded-strings
JimBobSquarePants 0fdcf04
Expand test and cleanup
JimBobSquarePants cda6b24
Bug fixes of reading and writing (UCS2 and EncodedString)
IldarKhayrutdinov 2ed1b6d
format
IldarKhayrutdinov d3c635f
Merge branch 'exif-encoded-strings' of github.com:IldarKhayrutdinov/I…
IldarKhayrutdinov e700656
Merge remote-tracking branch 'upstream/master' into exif-encoded-strings
IldarKhayrutdinov ac9a98a
cleanup
IldarKhayrutdinov 7b5dd17
cleanup
IldarKhayrutdinov 3054c5b
add encoded string tags to common tests
IldarKhayrutdinov 5dcbcfd
add test tag
IldarKhayrutdinov 361eb85
comment
IldarKhayrutdinov 62ca842
Add test
IldarKhayrutdinov 19a7b8c
update JIS test
IldarKhayrutdinov c292e65
comment
IldarKhayrutdinov d01dfe8
change JIS encoding, update test
IldarKhayrutdinov ab3ca30
cleanup
IldarKhayrutdinov 855d1aa
minor test
IldarKhayrutdinov 5d50298
memory improvements
IldarKhayrutdinov a5182b0
Merge branch 'master' into exif-encoded-strings
JimBobSquarePants fddfee2
Update DC-X008-Translation-2019-E.pdf
JimBobSquarePants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright (c) Six Labors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| namespace SixLabors.ImageSharp.Metadata.Profiles.Exif | ||
| { | ||
| /// <content/> | ||
| public abstract partial class ExifTag | ||
| { | ||
| /// <summary> | ||
| /// Gets the UserComment exif tag. | ||
| /// </summary> | ||
| public static ExifTag<EncodedString> UserComment { get; } = new ExifTag<EncodedString>(ExifTagValue.UserComment); | ||
|
|
||
| /// <summary> | ||
| /// Gets the GPSProcessingMethod exif tag. | ||
| /// </summary> | ||
| public static ExifTag<EncodedString> GPSProcessingMethod { get; } = new ExifTag<EncodedString>(ExifTagValue.GPSProcessingMethod); | ||
|
|
||
| /// <summary> | ||
| /// Gets the GPSAreaInformation exif tag. | ||
| /// </summary> | ||
| public static ExifTag<EncodedString> GPSAreaInformation { get; } = new ExifTag<EncodedString>(ExifTagValue.GPSAreaInformation); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/ImageSharp/Metadata/Profiles/Exif/Values/EncodedString.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright (c) Six Labors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using System; | ||
|
|
||
| namespace SixLabors.ImageSharp.Metadata.Profiles.Exif | ||
| { | ||
| /// <summary> | ||
| /// The EXIF encoded string structure. | ||
| /// </summary> | ||
| public readonly struct EncodedString : IEquatable<EncodedString> | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="EncodedString" /> struct. | ||
| /// </summary> | ||
| /// <param name="text">The text.</param> | ||
| public EncodedString(string text) | ||
| : this(text, EncodedStringCode.Unicode) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="EncodedString" /> struct. | ||
| /// </summary> | ||
| /// <param name="text">The text.</param> | ||
| /// <param name="code">The code.</param> | ||
| public EncodedString(string text, EncodedStringCode code) | ||
| { | ||
| this.Text = text; | ||
| this.Code = code; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the text. | ||
| /// </summary> | ||
| public string Text { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the character ode. | ||
| /// </summary> | ||
| public EncodedStringCode Code { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool Equals(object obj) => obj is EncodedString other && this.Equals(other); | ||
|
|
||
| /// <inheritdoc/> | ||
| public bool Equals(EncodedString other) | ||
| { | ||
| return this.Text == other.Text && this.Code == other.Code; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int GetHashCode() => | ||
| HashCode.Combine(this.Text, this.Code); | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string ToString() => this.Text; | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/ImageSharp/Metadata/Profiles/Exif/Values/EncodedStringCode.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) Six Labors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| namespace SixLabors.ImageSharp.Metadata.Profiles.Exif | ||
| { | ||
| /// <summary> | ||
| /// The 8-byte The character code enum. | ||
| /// </summary> | ||
| public enum EncodedStringCode | ||
| { | ||
| /// <summary> | ||
| /// The ASCII ITU-T T.50 IA5 character code. | ||
| /// </summary> | ||
| ASCII, | ||
|
|
||
| /// <summary> | ||
| /// The JIS X208-1990 character code. | ||
| /// </summary> | ||
| JIS, | ||
|
|
||
| /// <summary> | ||
| /// The Unicode character code. | ||
| /// </summary> | ||
| Unicode, | ||
|
|
||
| /// <summary> | ||
| /// The undefined character code. | ||
| /// </summary> | ||
| Undefined | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright (c) Six Labors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using System.Globalization; | ||
|
|
||
| namespace SixLabors.ImageSharp.Metadata.Profiles.Exif | ||
| { | ||
| internal sealed class ExifEncodedString : ExifValue<EncodedString> | ||
| { | ||
| public ExifEncodedString(ExifTag<EncodedString> tag) | ||
| : base(tag) | ||
| { | ||
| } | ||
|
|
||
| public ExifEncodedString(ExifTagValue tag) | ||
| : base(tag) | ||
| { | ||
| } | ||
|
|
||
| private ExifEncodedString(ExifEncodedString value) | ||
| : base(value) | ||
| { | ||
| } | ||
|
|
||
| public override ExifDataType DataType => ExifDataType.Undefined; | ||
|
|
||
| protected override string StringValue => this.Value.Text; | ||
|
|
||
| public override bool TrySetValue(object value) | ||
| { | ||
| if (base.TrySetValue(value)) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| switch (value) | ||
| { | ||
| case string stringValue: | ||
| this.Value = new EncodedString(stringValue); | ||
| return true; | ||
| case byte[] bytes: | ||
| this.Value = new EncodedString(ExifConstants.DefaultAsciiEncoding.GetString(bytes)); | ||
| return true; | ||
| default: | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| public override IExifValue DeepClone() => new ExifEncodedString(this); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.