Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i doing windows application when i scan image file this size is 10mb .this image file i want to compress before sending server.i want to send this file web application / server. so how to do so please give me suggestion.
Posted
Updated 27-Dec-13 21:36pm
v2
Comments
BillWoodruff 28-Dec-13 3:17am    
What format is the scan file in ? Are you sure it is not already compressed ?
Member 10279329 28-Dec-13 3:46am    
image file is not already compressed .i want to compress image such as 1-3 mb compress 20%,3-5mb compress 30%.how to do.
Aydin Homay 28-Dec-13 3:55am    
Winch one dot net is your platform ?

Compressing images is not always as simple as you might think - or as desirable.
Some formats are already compressed - JPG, PNG for example - and trying to compress them further can result in larger file sizes. Others are not compress - BMP for example - and these can be compressed using ZIP or RAR pretty well.

The other alternative is to try converting your image to a different file format, or saving it using different software or settings to the same format - but beware! Some formats like JPG use a lossy compression technique which can get astounding results, but which does so by "throwing information away" and this may impact the results later.

Check the scan format, and see if the original software can generate acceptable images in a compressed format first, then look at something like ZipLib to compress bitmaps for transfer later.
 
Share this answer
 
Hi

I am 100% agree with Solution #1 but if you want to compress still you can follow of these links:

Image Format Conversion in .NET[^]
Compress Image to a given size
Compress Image files using C#
Compress images with jpeg codec in C#


Best Regards.
 
Share this answer
 
thanks for reply me .i doing code following code


bool b = false;
string destimage = ConfigurationManager.ConnectionStrings["scanfilepath"].ConnectionString.ToString();
string saveimagepath = ConfigurationManager.ConnectionStrings["scan"].ConnectionString.ToString();

System.Drawing.Image tempImage = null;

try
{
FileStream fs = new FileStream(saveimagepath + imagename, FileMode.Open, FileAccess.Read);

tempImage = System.Drawing.Image.FromStream(fs);




FileInfo file = new FileInfo(saveimagepath+imagename);

Int64 imagesize = file.Length;
if (imagesize < 1024000 )
{

SaveJpeg(destimage + imagename, tempImage, 3);
b = true;

}


if (imagesize > 1024000 && imagesize <= 3072000)
{

SaveJpeg(destimage + imagename, tempImage, 20);
b = true;

}
catch (Exception jj)
{
MessageBox.Show("select image");

}
return b;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900