Skip to content

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

@rwg0

Description

@rwg0

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions