Bug 58037 - Image.Save(Stream, encoder, perameters) does not use compression level
Summary: Image.Save(Stream, encoder, perameters) does not use compression level
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: 5.0 (2017-02)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-10 08:55 UTC by Roman
Modified: 2017-07-10 08:55 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Example project (9.95 KB, application/gzip)
2017-07-10 08:55 UTC, Roman
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 58037 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Roman 2017-07-10 08:55:02 UTC
Created attachment 23429 [details]
Example project

Hello Guys! I work with pictures with jpeg format.
I need draw some logo over source image and tha save image to jpeg without compressing (high quality).
So my code:

            using(Image img = Image.FromStream(openFileDialog1.OpenFile())) //source image has size 298 000 bytes
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    ImageCodecInfo jpegEncoder = GetEncoder(ImageFormat.Jpeg);
                    System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
                    EncoderParameters myEncoderParameters = new EncoderParameters(1);
                    EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L); //I can use 50L, 100L, 75L but it's not difference what number I direct - result is equal always
                    myEncoderParameters.Param[0] = myEncoderParameter;
                    img.Save(memStream, jpegEncoder, myEncoderParameters);
                    byte[] buff = memStream.ToArray();
                    Console.WriteLine("Size = {0}", buff.Length);          //result image has size 38 900 bytes
                }
            }

        private ImageCodecInfo GetEncoder(ImageFormat format)
        {
            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
            foreach (ImageCodecInfo codec in codecs)
            {
                if (codec.FormatID == format.Guid)
                {
                    return codec;
                }
            }
            return null;
        }

It's not difference what level quality I set, because result will be equal always. Result image is compressed with losing quality.
But in OS Windows it works excellent.
Maybe must I try a GTK-Sharp/Cairo for resolving this issue?