473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to compress an JPEG file wtih high quality?

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
1 11463
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
11
by: Shiperton Henethe | last post by:
Dreamweaver 4 Hi Can anyone recommend a decent utility for compressing HTML that is safe - i.e. that *definitely* doesn't mess with the appearance in any browsers. I run a growing website...
10
by: Ryan Cooper | last post by:
Can anyone give me an idea or better yet, a code sample, demonstrating how to parse a JPEG header and search the header for markers located in the stream? Basically, I need to analyze an...
5
by: Jigar Mehta | last post by:
Hye Friends!!, Happy New Year!! I am Jigar Mehta from India. Currently I am working on a project in which I need to compress some images on the harddisk... I want to make an engine that reads...
10
by: rtilley | last post by:
Hope it's not inappropriate to post this here. Could someone critique my code? I have no Python programmers in my office to show this to. The script works OK, but should I do it differently? I...
1
by: Smokey Grindel | last post by:
I have a bitmap object I want to return as a JPEG image with a compression set at 90% and progressive passes enabled, how can I do this in .NET 2.0? Progressive passes are not necessary but the...
4
by: Greg | last post by:
I've searched everywhere for a solution Microsoft .NET Framework V 2.0.50727 AutoEventWireup="false" image2.aspx resize an image on the fly but Page_Load is triggered twice: Any suggestion?...
5
by: jayharvard1 | last post by:
Hello All. I'm trying to create jpegs out of data that is stored in a binary blob format in an RDBMS (MS Access). I've tried writing the jpeg directly: while not rs.EOF: op = file(imgdir + "\\"...
2
by: Zuhaib Hyder | last post by:
string stFileName = "abc"; string stFullFilePath = Server.MapPath("images/" + stFileName + ".jpg"); System.Drawing.Image i = System.Drawing.Image.FromFile(stFullFilePath); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.