如何在发送服务器之前压缩扫描文件。 [英] how to compress scanned file before sending server.

查看:123
本文介绍了如何在发送服务器之前压缩扫描文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我扫描图像文件时我正在做Windows应用程序这个大小是10mb。这个图像文件我想在发送server.i之前压缩。我想发送这个文件web应用程序/服务器。那么怎么做请给我一些建议。

解决方案

压缩图像并不总是你想象的那么简单 - 或者说是可取的。

某些格式已经被压缩 - 例如JPG,PNG - 并且尝试进一步压缩它们会导致文件更大。其他的不是压缩 - 例如BMP - 这些可以很好地使用ZIP或RAR进行压缩。



另一种方法是尝试将图像转换为其他文件格式,或使用不同的软件或设置将其保存为相同的格式 - 但要注意!像JPG这样的某些格式使用有损压缩技术可以获得惊人的结果,但是通过抛弃信息来实现这一点,这可能会影响以后的结果。



检查扫描格式,并查看原始软件是否可以首先以压缩格式生成可接受的图像,然后查看类似ZipLib的内容以压缩位图以便以后传输。






我100%同意解决方案#1,但如果你想压缩仍然可以关注这些链接:



.NET中的图像格式转换 [ ^ ]

将图像压缩到给定大小

< a href =http://geekswithblogs.net/bu llpit / archive / 2009/04/29 / compress-image-files-using-c.aspx>使用C#压缩图像文件

使用C#中的jpeg编解码器压缩图像





最好的问候。


感谢您的回复。我在代码后面做代码





bool b = false;

string destimage = ConfigurationManager.ConnectionStrings [scanfilepath]。ConnectionString.ToString();

string saveimagepath = ConfigurationManager.ConnectionStrings [scan]。ConnectionString.ToString();



System.Drawing.Image tempImage = null;



尝试

{

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



tempImage = System.Drawing.Ima ge.FromStream(fs);









FileInfo file = new FileInfo(saveimagepath + imagename);



Int64 imagesize = file.Length;

if(imagesize< 1024000)

{



SaveJpeg(destimage + imagename,tempImage,3);

b = true; < b / b






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

{



SaveJpeg(destimage + imagename,tempImage,20);

b = true;



}

catch(例外jj)

{

MessageBox.Show (选择图像);



}

返回b;

}


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.

解决方案

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.


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.


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;
}


这篇关于如何在发送服务器之前压缩扫描文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆