public static SaveJPGWithCompressionSetting ( Stream imageStream, string szFileName ) : Stream | ||
imageStream | Stream | |
szFileName | string | |
return | Stream |
public static Stream SaveJPGWithCompressionSetting(Stream imageStream, string szFileName)
{
Bitmap imageFile = new Bitmap(imageStream);
try
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter(Encoder.Quality, (long)90);
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
imageFile.Save(szFileName, ici, eps);
}
catch
{
imageFile.Save(szFileName);
}
StreamReader sr = new StreamReader(szFileName);
return sr.BaseStream;
}
#endregion