Skip to content

"Bit depth is not supported or not valid" on saving PNG #935

@xakep139

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

Setting ColorType property on PngEncoder settings causes NotSupportedException.
Here's the stacktrace:

   at SixLabors.ImageSharp.Formats.Png.PngEncoderCore.Encode[TPixel](Image`1 image, Stream stream)
   at SixLabors.ImageSharp.Formats.Png.PngEncoder.Encode[TPixel](Image`1 image, Stream stream)
   at SixLabors.ImageSharp.ImageExtensions.Save(Image source, String filePath, IImageEncoder encoder)
   at ImageSharpTest.Program.Main(String[] args) in C:\Users\User\Documents\Visual Studio 2019\Projects\ImageSharpTest\Program.cs:line 16

Steps to Reproduce

using (var image = Image.Load("image.png"))
{
    image.Save("output.png", new PngEncoder { ColorType = PngColorType.RgbWithAlpha });
}

with image image.zip

Just adding BitDepth = PngBitDepth.Bit8 to PngEncoder settings solves this problem.

System Configuration

  • ImageSharp version: 1.0.0-dev002749
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on):
  • .NET Framework version:
  • Additional information:

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions