Skip to content

V3 Use EXIF byte order for EXIF encoded strings. #2944

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 3 commits into from
Jun 12, 2025

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #2906

A backport of #2943 for V3.

Copilot

This comment was marked as outdated.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request backports changes to ensure that EXIF encoded strings are interpreted using the EXIF byte order. Key changes include:

  • Addition of a new test case for Issue2906.
  • Updates to ExifEncodedString and ExifEncodedStringHelpers to handle a ByteOrder parameter.
  • Adjustments to ExifReader and ExifTag for improved endianness management.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Images/Input/Webp/issues/Issue2906.webp Adds a new Git LFS pointer file for testing.
tests/ImageSharp.Tests/TestImages.cs Registers the new test image constant.
tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs Introduces a new test verifying proper decoding for Issue2906.
src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs Adds a ByteOrder overload for TrySetValue and defaults to LittleEndian in the parameterless override.
src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs Updates equality operators to handle nullable values.
src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs Refactors endianness handling, ensuring ByteOrder is set based on IsBigEndian.
src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs Updates methods to accept and use ByteOrder, with BOM detection logic for Unicode.
Comments suppressed due to low confidence (2)

src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs:105

  • Consider parameterizing or deriving the ByteOrder for GetDataLength to reflect the actual EXIF byte order, rather than defaulting to LittleEndian.
(uint)GetEncoding(encodedString.Code, ByteOrder.LittleEndian).GetByteCount(encodedString.Text) + CharacterCodeBytesLength;

src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs:112

  • Consider using the actual EXIF byte order for encoding the string in Write, instead of hardcoding LittleEndian, to ensure consistency with the rest of the EXIF handling.
int count = Write(GetEncoding(encodedString.Code, ByteOrder.LittleEndian), text, destination[CharacterCodeBytesLength..]);

@JimBobSquarePants JimBobSquarePants merged commit abf46b7 into release/3.1.x Jun 12, 2025
8 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/v3-issue-2906 branch June 12, 2025 13:06
This was referenced Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EXIF UserComment tag writes Unicode text in UTF-16LE instead of UTF-16BE as specified in the standard
1 participant