473,479 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 11470
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
3180
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
2464
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
19466
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
11635
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
11017
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
7803
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
3799
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
6372
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
9350
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
7019
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
7067
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...
1
6719
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
6847
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
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
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...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.