Skip to content

Commit

Permalink
ImageSharp: Fix jpeg colorspace hint
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Sep 9, 2023
1 parent f460082 commit 1f41baa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion NAPS2.Images.ImageSharp/ImageSharpImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ private static ImageEncoder GetImageEncoder(ImageFileFormat imageFormat, ImageSa
{
ImageFileFormat.Bmp => (ImageEncoder) new BmpEncoder(),
ImageFileFormat.Png => new PngEncoder(),
ImageFileFormat.Jpeg => new JpegEncoder { Quality = options.Quality == -1 ? 75 : options.Quality },
ImageFileFormat.Jpeg => new JpegEncoder
{
Quality = options.Quality == -1 ? 75 : options.Quality,
// ImageSharp will automatically save an RGB24 image as Grayscale if the actual image colors are gray.
// We prevent that here if the caller specified an RGB PixelFormatHint.
ColorType = options.PixelFormatHint >= ImagePixelFormat.RGB24 ? JpegEncodingColor.Rgb : null
},
ImageFileFormat.Tiff => new TiffEncoder(),
_ => throw new InvalidOperationException()
};
Expand Down

0 comments on commit 1f41baa

Please sign in to comment.