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

Allow decoding Tiff of different frame size. #2788

Merged
merged 5 commits into from
Aug 18, 2024
Merged

Conversation

JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Aug 1, 2024

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

  • Decode multiframe Tiff of different size.
  • Encode multiframe Tiff of different size.
  • Trim transparent pixels on image save?

See the discussion in #1982
Decoding is fairly trivial. We just needed to pass the correct parameters to the various internal types and draw to frames matching the root frame dimensions.

I don't know whether it is actually possible to trim transparent pixels on encode as there's no guarantee that the pixel format we have decoded to supports transparency. I guess we could add some sort of ChromaKeyColor property to the encoder and trim any bounding pixels matching that value?

I'll likely need assistance writing a performant trimming algorithm (My SIMD is rusty)

I've actually figured out a very neat way to handle all this transparently:

First off, we track the encoded dimensions in the same manner as ICO and CUR formats that ensures the frames are encoded at a configurable size.

By adding handling methods to the metadata APIs that run after processing a transformed image we can then automatically update those properties to scale with the transform. This mean you can load a Tiff Mipmap, resize the image and save each frame encoding only the relevant data!! 😄

In addition, I've normalized the ImageFrame.Size() method to now match the Image.Size property.

@JimBobSquarePants JimBobSquarePants changed the title WIP: Allow decoding Tiff of different frame size. Allow decoding Tiff of different frame size. Aug 8, 2024
@JimBobSquarePants JimBobSquarePants marked this pull request as ready for review August 8, 2024 14:11
@JimBobSquarePants JimBobSquarePants added this to the v4.0.0 milestone Aug 11, 2024
@JimBobSquarePants JimBobSquarePants added formats:tiff area:metadata breaking Signifies a binary breaking change. labels Aug 11, 2024
@JimBobSquarePants JimBobSquarePants merged commit 5c28129 into main Aug 18, 2024
5 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/multisize-tiff branch August 18, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metadata breaking Signifies a binary breaking change. formats:tiff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant