By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

How to compress an JPEG file wtih high quality?

P: n/a
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.Qu ality, 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!

Nov 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Is anyone kown how to fix it?
On Nov 6, 5:24 pm, ironpythons...@gmail.com wrote:
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.Qu ality, 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!
Nov 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.