简体   繁体   English

有没有办法使用C#压缩分页的.tiff文件?

[英]is there a way to compress a paged .tiff file using C#?

At the end of my process, I need to upload several paged .tiff file images to a website. 在我的流程结束时,我需要将几个分页的.tiff文件图像上传到网站。 The files need to be very small, 500kb or less when i upload them. 上传文件时,文件需要非常小,500kb或更少。

The problem is, even with me resizing them a lot but at the same time being able to read a few lines of text that are in some of them, they are around 1mb each or so. 问题是,即使我对它们进行了大量调整,但同时能够阅读其中一些文本中的几行文本,它们大约每个大约1mb。

I first resize all images going into the tiff files but it's not enough. 我首先调整所有进入tiff文件的图像,但这还不够。 I need a way to change the quality of them to decrease their size as well. 我需要一种方法来改变它们的质量以减小它们的尺寸。

Can C# do this or would I need a third party software to do it? C#可以这样做,还是需要第三方软件才能做到这一点?

The files being uploaded MUST be .tiff. 上传的文件必须是.tiff。

You don't provide much detail about your data, so can only make some guesses as to what you might need to look at. 您没有提供有关数据的详细信息,因此只能对您可能需要查看的内容进行一些猜测。

First, can you loose some resolution? 首先,你能解决一些问题吗? Can you make the images smaller? 你能让图像更小吗?

Second, can you loose some color depth? 第二,你可以放松一些颜色深度吗? Are you saving the files in a color format when bilevel or greyscale images would suffice? 当双层或灰度图像足够时,您是以彩色格式保存文件吗?

Third, how clean are these images? 第三,这些图像有多干净? Are they photos, scanned documents, what? 他们是照片,扫描文件,什么? If they are scanned documents of text or drawings, then some pre-processing to remove noise can make a significant difference in size. 如果它们是扫描文本或图纸的文档,那么一些预处理以消除噪声可以在尺寸上产生显着差异。

Lastly, what compression method are you saving the file with? 最后,您使用什么压缩方法保存文件? Only a lossy format is going to give you the highest degree of compression is most circumstances. 在大多数情况下,只有有损格式会给你最高程度的压缩。

Based on your follow-up: 根据您的后续行动:

1) If you can make smaller, this of course saves significant storage space. 1)如果你可以做得更小,这当然可以节省大量的存储空间。 Determine what is the minimum acceptable resolution that they need to be and standardize on that. 确定他们需要的最低可接受分辨率是什么,并对其进行标准化。

2) If you need to persist color, then this step might not be as effective, since you would have to algorithmically decrease the dynamic range of colors used in the image to an acceptable level before compressing. 2)如果你需要保持颜色,那么这一步可能不那么有效,因为你必须在压缩之前通过算法将图像中使用的颜色的动态范围减小到可接受的水平。 If you are not sure what this means, then you would probably best skip considering this completely unless you can spend time learning more about image processing and/or using a image processing library that will simplify this for you. 如果您不确定这意味着什么,那么除非您花时间了解有关图像处理的更多信息和/或使用可以简化此操作的图像处理库,否则您最好不要完全考虑这一点。

3) I don't think you addressed this in your comments. 3)我认为你在评论中没有提到这一点。 If you want more precise help, you should update your original question and add much more detail about what you are trying to accomplish. 如果您需要更精确的帮助,您应该更新原始问题并添加更多有关您要完成的内容的详细信息。 Provide some explanations of what/why you need to do in order to help determine what tradeoffs make sense. 提供一些解释,说明您需要做什么/为什么,以帮助确定哪些权衡是有意义的。

4) Yes, JPG is a lossy format, but I think you may be confusing a few different things (or I may not be understanding your intent from your description). 4)是的,JPG是一种有损格式,但我认为你可能会混淆一些不同的东西(或者我可能不会从你的描述中理解你的意图)。 If you are first resizing your original images down into a new JPG file (an intermediate image file), then you are building a TIFF file and inserting the resized JPG as a source image into a multi-page TIFF and saving that, then you need to realize that the process of how the files are compressed in the intermediate files do not necessarily have any correlation with the compression format used in the TIFF file. 如果您首先将原始图像调整为新的JPG文件(中间图像文件),那么您正在构建TIFF文件并将调整大小的JPG作为源图像插入到多页TIFF中并保存,然后您需要要意识到在中间文件中如何压缩文件的过程不一定与TIFF文件中使用的压缩格式有任何关联。 Depending on what you are using to build and create the TIFF file, the compression format used in the TIFF is done separately and you probably need to specify those parameters when you save that file. 根据您用于构建和创建TIFF文件的内容,TIFF中使用的压缩格式是单独完成的,您可能需要在保存该文件时指定这些参数。 If this is what you are doing, then the intermediary process of saving the JPG files may be increasing the size a bit. 如果这是你正在做的事情,那么保存JPG文件的中间过程可能会增加一些大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM