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

Ensure jpeg encoder is immutable. #1779

Merged
merged 2 commits into from
Oct 19, 2021
Merged

Conversation

JimBobSquarePants
Copy link
Member

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

Fixes #1712

@codecov
Copy link

codecov bot commented Oct 10, 2021

Codecov Report

Merging #1779 (d5cea15) into master (424d4f9) will decrease coverage by 0.00%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1779      +/-   ##
==========================================
- Coverage   84.49%   84.49%   -0.01%     
==========================================
  Files         849      849              
  Lines       37252    37251       -1     
  Branches     4385     4384       -1     
==========================================
- Hits        31477    31475       -2     
- Misses       4916     4917       +1     
  Partials      859      859              
Flag Coverage Δ
unittests 84.49% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ImageSharp/Formats/Jpeg/JpegEncoder.cs 100.00% <ø> (+11.11%) ⬆️
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs 94.94% <75.00%> (-0.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 424d4f9...d5cea15. Read the comment docs.

Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

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

A few cosmetic suggestions, otherwise looks good!

/// returns <see langword="null"/> defering the field assignment
/// to <see cref="InitQuantizationTables(int, JpegMetadata, out Block8x8F, out Block8x8F)"/>.
/// </summary>
private static JpegColorType? SetFallbackColorType<TPixel>(Image<TPixel> image)
Copy link
Member

Choose a reason for hiding this comment

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

I recommend to rename this to GetFallbackColorType(), since it doesn't change anything.

JpegMetadata metadata = image.Metadata.GetJpegMetadata();
if (IsSupportedColorType(metadata.ColorType))
{
colorType = metadata.ColorType;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we can return metadata.ColorType here, so the indentation with colorType is null becomes unnecessary.

@JimBobSquarePants JimBobSquarePants merged commit 07d50d0 into master Oct 19, 2021
@JimBobSquarePants JimBobSquarePants deleted the js/jpeg-encoder-color-type branch October 19, 2021 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JpegEncoder may alter its state after image encoding.
2 participants