Skip to content
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

ExifTag.TimeZoneOffset is defined as uint[], but the TIFF spec defines it as signed short #2437

Closed
4 tasks done
rwg0 opened this issue Apr 13, 2023 · 4 comments · Fixed by #2541
Closed
4 tasks done

Comments

@rwg0
Copy link

rwg0 commented Apr 13, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.0.1

Other ImageSharp packages and versions

?

Environment (Operating system, version and so on)

Windows 10 x64

.NET Framework version

.NET 7

Description

The TimeZoneOffset Exif tag is defined in the code as a uint[] (

public static ExifTag<uint[]> TimeZoneOffset { get; } = new ExifTag<uint[]>(ExifTagValue.TimeZoneOffset);
)

However, the specifications for TIFF/EP which defines that tag seem to require a signed short (optionally two signed shorts). See Page 19 and 40 of the TIFF/EP spec : https://web.archive.org/web/20060212163025/http://www.map.tu.chiba-u.ac.jp/IEC/100/TA2/recdoc/N4378.pdf

This requirement is also encoded in the TIFF verification code in JHove, which then flags the file as non-conformant (https://jhove.openpreservation.org/modules/tiff/tags/ , https://jhove.openpreservation.org/)

As a side note, since ExifTag doesn't have a public constructor, I cannot create my own tags to work around this issue (or to add custom tags to the file).

Steps to Reproduce

Set the DateTimeOffsetTag in a tiff file, then save the file

var image = Image.Load(sourceTifFile);
image.Frames[0].Metadata.ExifProfile = new ExifProfile();
image.Frames[0].Metadata.ExifProfile.SetValue(ExifTag.TimeZoneOffset, new uint[] {1});
image.Save(outputTifFile);

Now run the output tiff file through jhove verification

robin@ubuntu:~$ jhove -m TIFF-hul Output.tif 
Jhove (Rel. 1.20.0, 2019-01-19)
 Date: 2023-04-13 13:33:05 PDT
 RepresentationInformation: Output.tif
  ReportingModule: TIFF-hul, Rel. 1.8 (2017-05-11)
  LastModified: 2023-04-13 13:27:13 PDT
  Size: 343128
  Format: TIFF
  Status: Not well-formed
  SignatureMatches:
   TIFF-hul
  ErrorMessage: Type mismatch for tag 34858; expecting 8, saw 4
  MIMEtype: image/tiff

You can install jhove on an ubuntu box with

sudo apt-get install jhove default-jre

Note: I ran the ImageSharp test code on Windows, just used Ubuntu for testing as the jhove install is easier

Images

No response

@dlemstra
Copy link
Member

That looks like a mistake indeed but changing this would introduce a breaking change. But I do wonder if anyone is using this since we implemented this incorrectly. Maybe we could patch this in a minor release and make a note about this minor breaking change in the release notes?

@rwg0
Copy link
Author

rwg0 commented Apr 14, 2023

To avoid a breaking change you could attribute the existing TimeZoneOffset property as [Obsolete] and add a new property with the correct definition.

@JimBobSquarePants
Copy link
Member

While it affects the public API I don’t consider bug fixes like this to require minor versions. I’d be happy shipping a fix without one.

@JimBobSquarePants
Copy link
Member

I'm happy for this to be fixed in v3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants