读取图像的头信息,而无需加载整个图像 [英] Reading image header info without loading the entire image

查看:132
本文介绍了读取图像的头信息,而无需加载整个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.net 3.5应用程序,将要处理大量的图像。我需要检查图像扩展是正确的,图像的高度和宽度,和PPI。我不希望加载整个图像到.NET图像或位图,这需要长期,并以资源密集型。我不能使用第三方插件或DLL,当然它需要做昨天

I have a .net 3.5 application that will be dealing with a large number of images. I need to check that the image extension is correct, the image height and width, and the PPI. I do not want to load the entire image into a .net image or bitmap, this will take to long and be to resource intensive. I can not use third party plug-ins or dlls, and of course it needs to be done yesterday.

所以,我读的文件的初始字节,检查魔的数字,以确保图像扩展相符,然后的高度和宽度的图像的大多数我需要处理图像类型。这是更快,更少的资源密集型。我可以用一点点帮助从一些图像类型的阅读PPI和两个类型的刚刚难倒我无法验证延伸至今。

So, I am reading the initial bytes of the files, checking the "magic" numbers to make sure the image extension matches, and then the height and width of the image for most of the image types I need to handle. This is much faster and less resource intensive. I could use a little help reading the PPI from some of the image types, and two of the types have just stumped me beyond validating the extension so far.

BMP,JPG,GIF和PNG我需要帮助读PPI。

BMP, JPG, GIF, and PNG I need help reading the PPI.

  • 在寻找像位于偏移XX。

TIF,EPS和PSD我需要帮助读书的高度,宽度和PPI。

TIF, EPS, and PSD I need help reading height, width, and PPI.

  • 我是pretty的多停留在EPS和PSD文件,以及任何有助于。

  • I am pretty much stuck on Eps and Psd files, and anything would help.

是的,我知道tiflib,它看起来很棒,而且这样比我更需要。更轻的版本,只处理的高度,宽度和PPI将是巨大的。如果非要我能做到这一点,但我希望有人都准备好了: - )

Yes I know about tiflib, it looks great, and way more than I need. A lighter version that handles only the height, width, and PPI would be great. If I have to I can do this, but I'm hoping someone all ready has :-)

推荐答案

所有字节位置承担的第一个字节在位置1,而不是0。

PNG文件宽度:字节9-12,身高:13-16字节,PPI:找112 72 89 115(十进制值)一个4字节的签名,字节1-4(以下)包含在X的像素单位,字节5-8包含单位在Y像素,字节9包含单位指示符(0 =未知,1 =米)。 PPI的存储在一个任选的组块,并且可以在所有的PNG不存在

PNG files Width: bytes 9-12, Height: bytes 13-16, PPI: look for a 4 byte signature of 112 72 89 115 (decimal values), bytes 1-4 (following) contain the X pixels per unit, bytes 5-8 contain the Y pixels per unit, byte 9 contains the unit specifier (0=unknown, 1=meter). The PPI is stored in an optional chunk and may not exist in all PNGs.

http://www.libpng.org/pub/ PNG /规格/ ISO /索引object.htm http://en.wikipedia.org /维基/ PNG_file_format

BMP文件宽度:字节18-21,身高:22-25字节,PPI:字节38-41包含每米在X像素,字节42-45包含每米在Y像素。

BMP files Width: bytes 18-21, Height: bytes 22-25, PPI: bytes 38-41 contain the X pixels per meter, bytes 42-45 contain the Y pixels per meter.

http://en.wikipedia.org/wiki/BMP_file_format

JPG文件 JPEG指的是COM pression,而JFIF是实际的文件存储格式。宽:,高:,PPI:字节11-12包含单位在X像素,字节13-14包含单位在Y像素。字节10包含该单元(0 =无单位,每英寸1 =象素,每cm 2 =像素)。

JPG files JPEG refers to the compression, while JFIF is the actual file storage format. Width: , Height: , PPI: bytes 11-12 contain the X pixels per unit, bytes 13-14 contain the Y pixels per unit. Byte 10 contains the unit (0=no units, 1=pixels per inch, 2= pixels per cm).

http://en.wikipedia.org/wiki/JPEG_File_Interchange_Format 和的 http://www.ecma-international.org/publications/files/ECMA -TR / TR-098.pdf

GIF文件宽度:字节7-8,身高:9-10字节,PPI:GIF文件不包含任何像素密度的信息

GIF files Width: bytes 7-8, Height: bytes 9-10, PPI: GIF files do not contain any pixel density information.

http://en.wikipedia.org/wiki/Graphics_Interchange_Format

我已经提供链接到其他格式,因为它们需要的格式的具体知识,以确定是否或其中所请求的信息被存储。

I have supplied links to the other formats as they require specific knowledge of the format to determine if or where the information you requested is stored.

http://partners.adobe.com/public/developer/tiff/ index.html的

http://en.wikipedia.org/wiki/Portable_Document_Format 和的 http://www.adobe.com/devnet/pdf/pdf_reference_archive.html

http://www.adobe.com/devnet-apps/photoshop/fileformatashtml /

这篇关于读取图像的头信息,而无需加载整个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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