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

Mutation to transparent background doesn't work sometimes #931

Closed
3 of 4 tasks
xakep139 opened this issue Jun 13, 2019 · 5 comments
Closed
3 of 4 tasks

Mutation to transparent background doesn't work sometimes #931

xakep139 opened this issue Jun 13, 2019 · 5 comments

Comments

@xakep139
Copy link
Contributor

xakep139 commented Jun 13, 2019

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

Description

I'm not sure that it's a bug, maybe I've just missed something, Before beta006 (more specifically, on version 1.0.0-dev001621) we made transparent background like this: https://github.com/SixLabors/Samples/blob/625dd0ace7c30ed9cb3dc7a48304471e0bd91b76/ImageSharp/AvatarWithRoundedCorner/Program.cs#L87
After #882 we moved to 1.0.0-dev002548 and changed logic to: https://github.com/SixLabors/Samples/blob/master/ImageSharp/AvatarWithRoundedCorner/Program.cs#L85 (but this could be reproduced on latest 1.0.0-dev002737 as well)
But some pictures have black background after upgrading, not transparent.

Steps to Reproduce

Sample project https://github.com/SixLabors/Samples/tree/master/ImageSharp/AvatarWithRoundedCorner could be used with the following image: image.zip
Here's the output of different versions of ImageSharp: outputs.zip

System Configuration

  • ImageSharp version: 1.0.0-dev002737
  • Other ImageSharp packages and versions: SixLabors.ImageSharp.Drawing 1.0.0-dev002737
  • Environment (Operating system, version and so on): Windows 10 Enterprise version 1809 build 17763.475
  • .NET Framework version: dotnet SDK 2.1.603
  • Additional information:
@JimBobSquarePants
Copy link
Member

Hi @xakep139

Your output images are 24bit. This can only happen when the PngEncoder instance has its ColorType property set to PngColorType.Rgb or when it is null and the PngMetadata within the image has the property set to PngColorType.Rgb.

You'll need to explicitly set the PngColorType to RgbWithAlpha in the encoder when encoding to the png to preserve transparency.

@xakep139
Copy link
Contributor Author

@JimBobSquarePants, thanks for the quick response! Changing ColorType for the encoder worked like a charm!
Should this be reflected in samples?

@JimBobSquarePants
Copy link
Member

Most definitely. We need to give those samples some love.

@antonfirsov
Copy link
Member

A reminder that I should take care of this when l'll touch the samples because of #907.

@xakep139
Copy link
Contributor Author

I suppose this issue should be closed ) Thanks for the help!

@xakep139 xakep139 changed the title Mutation to transparent background don't work sometimes Mutation to transparent background doesn't work sometimes Jun 18, 2019
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

No branches or pull requests

3 participants