当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - What is the best web viewable format to save a TIF with a 1 bit depth?

问题描述:

I want to convert TIF to an image type that is viewable in a web page.

The TIFs are black and white so JPG does not work well at all and ends up even larger after conversion.

Here are some tests I have performed using C# and Image.Save to do the conversion:

Orignal TIF is 7KB (bit depth: 1).

Converted to:

  • JPG: 101KB (bit depth: 24)
  • BMP: 256KB (bit depth: 1)
  • GIF: 17KB (bit depth: 8)
  • PNG: 11KB (bit depth: 1)

I then converted a multipage TIF which has 3 pages. Original size was 134KB (bit depth: 1).

Converted 3 images totals:

  • JPG: 1324KB (bit depth: 24)
  • BMP: 768KB (bit depth: 1)
  • GIF: 221KB (bit depth: 8)
  • PNG: 155KB (bit depth: 1)

I am starting with a multipage TIF and I need to convert to be viewable in a browser. It looks like PNG would be the best format to use based on my basic tests I have outlined above. Are there other image formats that I should be using / considering?

Are the any other options I am missing to get the file size down?

EDIT: I haved added more information regarding the bit depth of each format. The BMP and PNG maintain the same bit depth as the TIF. Is there a way to reduce the GIF or JPG bit depth to hopefully reduce the size significantly?

网友答案:

PNG is certainly your best choice here.

The reason your PNG ends up larger than the original TIF might be that the runtime doesn't do all the compression it possibly could. If you really need to compress every last little byte out of the PNG file, I would suggest using a tool like AdvancePNG or OptiPNG in order to compress the PNGs after you write them out. The author of OptiPNG has written a good article with links to a few other PNG optimizers.

网友答案:

Use PNG, it supports 1-bit color mode and works even in IE4 (if you don't need partial transparency). Do your customers use IE3?

网友答案:

A few years ago I might have shied away from PNG, but now it just works. and there are plenty of hack scripts to get it to work with IE 5 and 6 so you can be safe for most users. If you really need compatibility offer both GIF & PNG.

分享给朋友:
您可能感兴趣的文章:
随机阅读: