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

Describe the page number tag #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drewnoakes
Copy link
Owner

@kwhopper could you review this and, if happy, merge it?

It seems to work on many of the ImageTestSuite TIFF files, however there are quite a few of those where the page numbers make little sense.

I used this page as a reference for the tag: http://www.awaresystems.be/imaging/tiff/tifftags/pagenumber.html

We only have a handful of multipage TIFF images that contain this tag, and this seems to work on most of them.
[CanBeNull]
public string GetPageNumberDescription()
{
var values = Directory.GetInt32Array(ExifDirectoryBase.TagPageNumber);
Copy link
Collaborator

Choose a reason for hiding this comment

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

All the specs I have seen describe this as a short array. Exiftool has it typed as ushort. When feasible, I typically try to keep the same data types in .NET as the spec. Not every array type is implemented, so can fall back on the 'as' operator:

var values = Directory.GetObject(ExifDirectoryBase.TagPageNumber) as ushort[];

Obviously, the parsed datatype isn't always to spec so you would have to test whether this works all the time. Doing this in Java isn't always possible, so int32 isn't so bad if you're trying to match code.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Agree. We don't have a GetInt16Array extension method for Directory and I wasn't feeling up to making one, partly because of the inconsistent mess that permitting type coercion within directories has left us with. We could call GetObject and cast, but GetInt32Array will convert the value if it's non-standard, which does tend to increase coverage.

@kwhopper
Copy link
Collaborator

I'm fine with this besides the small datatype quibble. It sounds like these values will either be unknown for the second value or wrong more often than not.

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

Successfully merging this pull request may close these issues.

2 participants