Skip to content

Converting Png to Jpg give a color background and not white (Asp.Net Core) #355

@FelixLeChat

Description

@FelixLeChat

Description

My goal is to generate renditions (thumbnail, and other size of the image) from an uploaded image (IFormFile, png or jpg).

When uploading a .png with transparency, the resulting image has a background of a color in the image and not a default white one.

Steps to Reproduce

        public static Stream GenerateCompressedOriginal(IFormFile file)
        {
            Stream outputStream = new MemoryStream();

            using (Image<Rgba32> image = Image.Load(file.OpenReadStream()))
            {
                image.SaveAsJpeg(outputStream, new JpegEncoder() { Quality = 80 });
            }

            return outputStream;
        }

From :
2553905512_listing_logo

To :
2553905512_preview

if i save the outputstream as a jpg. the error occur. The image variable has also this background in color and not white.

System Configuration

  • ImageSharp version: 1.0.0-alpha9-00194
  • Environment (Operating system, version and so on): windows 10
  • .NET Framework version: .Net Standard 1.6

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