Skip to content

Mutation to transparent background doesn't work sometimes #931

Closed

Description

@xakep139

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:

Activity

  1. JimBobSquarePants commented on Jun 13, 2019

    @JimBobSquarePants
    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.

  2. xakep139 commented on Jun 13, 2019

    @xakep139
    ContributorAuthor

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

  3. JimBobSquarePants commented on Jun 13, 2019

    @JimBobSquarePants
    Member

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

  4. antonfirsov commented on Jun 13, 2019

    @antonfirsov
    Member

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

  5. xakep139 commented on Jun 13, 2019

    @xakep139
    ContributorAuthor

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

  6. changed the title [-]Mutation to transparent background don't work sometimes[/-] [+]Mutation to transparent background doesn't work sometimes[/+] on Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions