Skip to content

Certain PNGs with transparent background are corrupted when written to filepath with JPG extension #1699

@atantapr

Description

@atantapr

Magick.NET version

Magick.NET-Q8-AnyCPU 13.10.0

Environment (Operating system, version and so on)

Windows 10, .NET Framework 4.8

Description

I have encountered 3 PNG images with transparent background which are corrupted when they are loaded by IM and then written to a new path with the JPG extension instead of PNG. This is how we normally change the output filetype when processing a file with IM, and I am not aware of a different method to make IM output the same file with a different filetype. We have not been able to reproduce this with any other PNGs with transparent background so far, and it's unclear to me what might be unique about these files that is causing the corruption.

The attached ZIP contains the original PNG files and the resaved JPG files which display the corruption. The first one becomes visibly blurred around the edges of the original image, and the background becomes white. The other two have their background become black instead of the expected white.

Can this be resolved with a code change on our end, or can it be fixed in Magick.NET / ImageMagick?

AffectedPNGsWithTransparentBackground.zip

Steps to Reproduce

MagickImage image = new MagickImage();
image.Read(pngPath);
image.Write(jpgPath);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions