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

Remove ImageFormat out params and return on Metadata #2317

Merged
merged 16 commits into from
Jan 15, 2023

Conversation

JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Jan 12, 2023

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

This PR replaces and build upon #2092. Touches #2231

  • Expose ImageInfo type for easier decoder implementation.
  • Add IImageInfo to Image.Metadata as IImageInfo? via the DecodedImageFormat property and set on decode.
  • Remove API overloads using the out IImageFormat parameter and cleanup.
  • Normalizes DetectFormat, Identify, and Load APIs to all throw UnknownImageFormatException on failure.
  • Updates ImageFormatManager.GetXX methods to throw UnknownImageFormatException on failure.
  • Add tests.

@stefannikolei Apologies but I sent you the wrong direction with your previous PR. It's best we return the none nullable type and throw when something goes wrong with the aforementioned APIs.

@JimBobSquarePants JimBobSquarePants changed the title WIP : Remove ImageFormat out params and return on Metadata Remove ImageFormat out params and return on Metadata Jan 14, 2023
@JimBobSquarePants JimBobSquarePants added this to the 3.0.0 milestone Jan 14, 2023
@JimBobSquarePants JimBobSquarePants added API codequality breaking Signifies a binary breaking change. labels Jan 14, 2023
@JimBobSquarePants JimBobSquarePants marked this pull request as ready for review January 14, 2023 11:23
@stefannikolei
Copy link
Contributor

@JimBobSquarePants all good. It's no wasted time. All are learning on this path.

stream,
s => this.Decode<TPixel>(options, s, default));

this.SetDecoderFormat(options.Configuration, image);
Copy link
Member

Choose a reason for hiding this comment

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

rather than calling this at every overload... could this not just happen inside the Decode() call above? well instead of calling the abstract Decode<>() directly create a DecodeInternal<>() (name?) that calls the abstract method and sets the decoder rather than have to repeat the call on every overload.

Copy link
Member Author

@JimBobSquarePants JimBobSquarePants Jan 14, 2023

Choose a reason for hiding this comment

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

Not that I can see. Each of the sync/async calls are different calling the generic/non-generic versions. The overloads are the abstract methods.

@@ -1,4 +1,4 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
Copy link
Contributor

@stefannikolei stefannikolei Jan 14, 2023

Choose a reason for hiding this comment

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

I think this Interface and the interface IImage are not longer used in the code. Can probably get dropped

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been considering this also.

IImageInfo is used in two places in ImageInfoExtensions to get the size and bounds.
IImage is only referenced by Image and is unused anywhere.

@tocsoft what do you think?

Copy link
Member Author

@JimBobSquarePants JimBobSquarePants Jan 15, 2023

Choose a reason for hiding this comment

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

OK. So, I actually ran with this and in my opinion, things look much better.

IImageInfo and IImage are gone.
ImageInfo is now unsealed and Image inherits that.
Size Size and Rectangle Bounds are now properties of ImageInfo not extension methods which remove the odd inconsistency between those extensions and the Width/Height properties,

Copy link
Member

@tocsoft tocsoft Jan 15, 2023

Choose a reason for hiding this comment

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

seems fine to me, we seem to be dropping interfaces where we can 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I think we went a little heavy on them originally and it actually limited our ability to improve in some areas.

What are your thoughts on the rest of the PR. OK to merge?

@JimBobSquarePants JimBobSquarePants merged commit 271dc99 into main Jan 15, 2023
@JimBobSquarePants JimBobSquarePants deleted the js/move-iimageformat branch January 15, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API breaking Signifies a binary breaking change. codequality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants