How to compress an JPEG file wtih high quality?

I

ironpythonster

Hi everyone, this should be a quick question.
I am writing a function to compress the Jpeg file,with
the API Image.Save(...) .

the code as follow that:

public static void Save(string imagePath, Bitmap image, int quality)
{
if (JpegQuality.Codec == null)
image.Save(imagePath,
System.Drawing.Imaging.ImageFormat.Jpeg);
else
{
EncoderParameters ep = new EncoderParameters();
ep.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
image.Save(imagePath, JpegQuality.Codec, ep);
ep.Dispose();
}
}

But use this function,the compressed photo would lost so much
info. e.g.:when a originality is about 1.5M large,
the compress result would get a file only about 30K(set the quality
gene as 85)

How could i compree a file larger than 1.5M to about only 1M?


Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top