question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`quality` parameter is ignored in `Bitmap.Save` with `.jpg`

See original GitHub issue

Describe the bug The parameter does not appear to have any effect and no warning is reported.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Bitmap (I used WriteableBitmap) of ~1920x1080
  2. Fill it with non-trivial data
  3. Call bitmap.Save("test.jpg", quality: 10) (I also tried 1)

Expected behavior You get a low quality version of the bitmap weighting under 100KB

Actual behavior You get a high quality file over 1MB in size. It appears the resulting file is actually a PNG instead of JPEG.

Screenshots N/A

Desktop (please complete the following information):

  • OS: Windows
  • Version 11.0.2

Issue Analytics

  • State:open
  • Created a month ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TETYYScommented, Aug 10, 2023

It appears the resulting file is actually a PNG instead of JPEG.

To be clear, check for file extension is not present here, it is always saved as PNG https://github.com/AvaloniaUI/Avalonia/blob/1896e8ad68dc0fdb6c1055d36a97b926e0a32f17/src/Skia/Avalonia.Skia/Helpers/ImageSavingHelper.cs#L57C51-L57C51

0reactions
lostmsucommented, Aug 10, 2023

I started working on support for image formats at least for saving. PR should be out in an hour or so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Parameter is not valid." when using saving bitmap
Im trying to save a bitmap jpg format with a specified encoding quality. However im getting an exception ("Parameter is not valid.
Read more >
Image.save - the parameter is invalid.
When I try to save the image into a new stream, the code is throwing "Parameter is not valid" exception. Facts: - The...
Read more >
How to Save PNG Images in C#
The "Quality" parameter above is actually ignored. Save as JPG. If you want to save the image as a JPG and specify the...
Read more >
problems with changing of image compression quality
No. The Quality parameter, if you supply it, will be ignored because PNG doesn't have a Quality setting. BB.
Read more >
How to: Set JPEG Compression Level
Each JPEG image is saved with a different quality level, by modifying the long value passed to the EncoderParameter constructor. A quality level ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found