I am trying to save a bitmap JPG format with a given encoding quality. However, im gets an exception ("The parameter is invalid.") When calling the save method.
If I leave the last two options in bmp.save, it works fine.
EncoderParameters eps = new EncoderParameters(1); eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 16); ImageCodecInfo ici = GetEncoderInfo("image/jpeg"); string outfile = outputpath + "\\" + fileaddition + sourcefile.Name; bmp.Save(outfile,ici,eps ); bmp.Dispose(); image.Dispose(); return true; } ImageCodecInfo GetEncoderInfo(string mimeType) { int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for (j = 0; j < encoders.Length; ++j) { if (encoders[j].MimeType == mimeType) return encoders[j]; } return null; } }
thanks
CruelIO
source share