Skip to content

Weird PNG resaving issue, broken image? #2498

@KLuuKer

Description

@KLuuKer

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

ImageSharp version

3.0.1 \ 3.0.2-alpha.0.27

Other ImageSharp packages and versions

Drawing 1.0.0-beta15.1 \ 15.14 Fonts 1.0.0-beta18 \ 19.19

Environment (Operating system, version and so on)

Windows 11 x64 AMD Ryzen

.NET Framework version

.net core 7.0.9

Description

input png gets turned into a purple mess
probably a broken file

looking at the original trough multiple image viewers works fine

  • windows explorer preview
  • irfanview 64 bit 4.54
  • irfanview 32 bit 4.62 (windows store app version)

p.s. hi i'm back with another random weird issue 😄 still love you guys and imagesharp
i already have the new feedz to test the latest builds if available

Steps to Reproduce

doesn't matter if converting 1 or multiple images at the same time

using var img = await Image.LoadAsync("original.png");

// this broken
await img.SaveAsPngAsync("output.png", new PngEncoder() { CompressionLevel = PngCompressionLevel.BestCompression });

// work around (i don't want to do this because i might end up using a higher amount of bits)
await img.SaveAsPngAsync("workaround.png", new PngEncoder() { CompressionLevel = PngCompressionLevel.BestCompression, ColorType = PngColorType.RgbWithAlpha });

// jpg is fine
await img.SaveAsJpegAsync("works.jpg", new JpegEncoder { SkipMetadata = false, Quality = 100 });

// webp also works
await img.SaveAsWebpAsync("lossy.webp", new WebpEncoder { EntropyPasses = 1, FileFormat = WebpFileFormatType.Lossy, Method = WebpEncodingMethod.BestQuality, NearLossless = true, Quality = 100, TransparentColorMode = WebpTransparentColorMode.Preserve });

Images

original input (also zipped to prevent "optimization"):
original.zip
original

broken output png:
png

working jpg (quality doesn't matter):
jpg

webp also works but file is not support 😄

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions