如何减少.tif文件的Bit Depth? [英] How can I reduce Bit Depth of a .tif file?

查看:139
本文介绍了如何减少.tif文件的Bit Depth?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用100 dpi扫描A4尺寸的图像为'.tif'格式。文件大小为2832 KB。现在我想将文件大小减小到50 KB。



我已经尝试减少比特深度,例如...



dim SourceName As String =C:\ Sample.tif

dim TargetName As String =C:\ Sample_Compress.tif

Dim tiff As Image

Dim enParams As New EncoderParameters(2)

Dim tifCodec As ImageCodecInfo = ImageCodecInfo.GetImageEncoders(3)



enParams.Param(0 )= New EncoderParameter(Encoder.Compression,

EncoderValue.CompressionLZW)



enParams.Param(1)= New EncoderParameter(Encoder.Quality) ,CLng(1))





tiff = Image.FromFile(SourceName)

Dim tempBM As New位图(tiff.Width,tiff.Height,PixelFormat.Format32bppArgb)



tempBM.SetResolution(tiff.Horizo​​ntalResolution,tiff.VerticalResolution)

Dim g1 As Graphics = Graphics.FromImage(tempBM)





g1.DrawIma geUnscaled(tiff,New Point(0,0))

tempBM.Save(TargetName,tifCodec,enParams)

tiff.Dispose()



--------------------



现在文件大小减少了到2832 KB到400 KB。如何减少到50 KB?

I have scan an A4 size Image with 100 dpi as '.tif' format. The file size stand 2832 KB. Now I want to reduce the file size to 50 KB.

I have already try to reduce the bit depth such as ...

dim SourceName As String = "C:\Sample.tif"
dim TargetName As String = "C:\Sample_Compress.tif"
Dim tiff As Image
Dim enParams As New EncoderParameters(2)
Dim tifCodec As ImageCodecInfo = ImageCodecInfo.GetImageEncoders(3)

enParams.Param(0) = New EncoderParameter(Encoder.Compression,
EncoderValue.CompressionLZW)

enParams.Param(1) = New EncoderParameter(Encoder.Quality, CLng(1))


tiff = Image.FromFile(SourceName )
Dim tempBM As New Bitmap(tiff.Width, tiff.Height, PixelFormat.Format32bppArgb)

tempBM.SetResolution(tiff.HorizontalResolution, tiff.VerticalResolution)
Dim g1 As Graphics = Graphics.FromImage(tempBM)


g1.DrawImageUnscaled(tiff, New Point(0, 0))
tempBM.Save(TargetName, tifCodec, enParams)
tiff.Dispose()

--------------------

Now the file size reduce to 2832 KB to 400 KB. How can I reduce to 50 KB ?

推荐答案

谁告诉您可以将文件压缩到任何预定义的值? :-)你已经有LZW(无损)压缩并得到了相当不错的结果。



嗯,你可以获得更少的每像素位数。如果你不需要不透明层, PixelFormat.Format24bppRgb 仍然相当不错。走下去......是可能的,但通常看起来很难看。此外,它取决于图像。如果您的颜色数量有限(几何图形), PixelFormat.Format1bppIndexed ,但这种情况很少见。你可以去任何地方,但我怀疑你能以这种方式取得好成绩。请参阅: http://msdn.microsoft .com / zh-CN / library / system.drawing.imaging.pixelformat%28v = vs.110%29.aspx [ ^ ]。



除此之外 - 您可以转到有损压缩领域,例如JPEG或有损PNG。一个警告:永远不要编辑使用有损压缩保存结果的图像:压缩的伪像会累积并使图像质量恶化而无法修复。压缩应该只进行一次。对任何中间结果仅使用无损压缩。请参阅:

http://en.wikipedia.org/wiki/Lossless_compression [< a href =http://en.wikipedia.org/wiki/Lossless_compressiontarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Lossy_compression [ ^ ],

http ://en.wikipedia.org/wiki/JPEG [ ^ ],

http://en.wikipedia.org/wiki/Portable_Network_Graphics#Compression [ ^ ]。



-SA
Who told you that you can compress the file to any predefined value? :-) You already have LZW (lossless) compression and got pretty good results.

Well, you can get less bits per pixel. If you don't need opacity layer, PixelFormat.Format24bppRgb is still quite good. Going down… is possible but usually looks ugly. Also, it depends on the image. If you have limited number of colors (geometric graphics), PixelFormat.Format1bppIndexed, but this is a rare situation. You can go anywhere lower, but I doubt you can get good results this way. Please see: http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat%28v=vs.110%29.aspx[^].

Other than that — you can move to the field of lossy compression, such as JPEG or lossy PNG. One warning: never edit images saving results using lossy compression: the artifacts of compression will accumulate and deteriorate the image quality beyond repair. The compression should be done only once. Use only lossless compression for any intermediate results. Please see:
http://en.wikipedia.org/wiki/Lossless_compression[^],
http://en.wikipedia.org/wiki/Lossy_compression[^],
http://en.wikipedia.org/wiki/JPEG[^],
http://en.wikipedia.org/wiki/Portable_Network_Graphics#Compression[^].

—SA


这篇关于如何减少.tif文件的Bit Depth?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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