public static void Save(Image img, string path, ImgCodes code, int quality) { var qualityParam = new EncoderParameter(Encoder.Quality, quality); var codecInfo = GetCodeInfo(code); var encoderParams = new EncoderParameters(1); encoderParams.Param[0] = qualityParam; img.Save(path, codecInfo, encoderParams); }
public static ImageCodecInfo GetCodeInfo(ImgCodes code) { return(ImageCodecInfo.GetImageEncoders().FirstOrDefault(m => m.MimeType == codes[code])); }