Re: Jpeg Compression Ratio

Ryan Heath <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <[email protected]>
We do something like this

EncoderParameters ep = new EncoderParameters(1);
ep.Param[0] = new EncoderParameter(Encoder.Quality, 80L);
using (FileStream fs = new FileStream(path, FileMode.Create))
{
  image.Save(fs, GetImageCodec("image/jpeg"), ep);
}

Where GetImageCodec is
ImageCodecInfo GetImageCodec(string mimeType)
{
  ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

  for (int i = 0; i < codecs.Length; i++)
  {
    if (codecs[i].MimeType == mimeType)
      return codecs[i];
  }

  return null;
}

HTH
// Ryan

On Fri, Nov 21, 2008 at 11:42 AM, Simon Robinson
<[email protected]> wrote:
> If I have a System.Drawing.Bitmap instance and want to save it as a jpg file, does anyone happen to know if there's a way to control the compression ratio it gets saved as?
>
> Ta :-)
>
> ===================================
> View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
>

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.