I am trying to save a JPEG image using the Bitmap class. I noticed that sharp edges always blur, regardless of the quality level that I specify. I realized that this is due to a subsample of one or more channels. How to disable subsampling while saving image?
I am currently using this code:
EncoderParameters parameters = new EncoderParameters(1); parameters.Param[0] = new EncoderParameter(Encoder.Quality, 85L); ImageCodecInfo codec = GetEncoderInfo("image/jpeg"); image.Save(path, codec, parameters);
Note
I know that JPEG is lost, but that is not a problem. If I use ImageMagick and save the image with the default settings, I get similar results. However, if I set a 1: 1: 1 subselect, the blur disappears.
I do not want to use PNG because I need better compression. If I save the image as BMP and then convert it manually to JPEG, I get great results without blurring. Therefore, the format here is not a problem.
source share