图像处理应用程序如何识别用户打开的文件?
图像处理应用程序如何识别用户打开的文件?
众所周知,图像处理应用程序可以打开所有已知的图像格式。我的问题是,图像处理应用程序如何知道它正在打开什么类型的文件。它将从文件扩展名中得知,或者它将以二进制方式打开文件并读取文件头,然后我将创建该文件类型的对象。
或任何已知的查找图像文件格式的方法。
对于上述问题,你如何设计你的系统。您将使用哪些设计模式。
提前致谢。
戒日
How Image Processing Applications identify the file which user opened?
As we already known Image Processing applications can open all known formats of Images. My question is, How image processing applications know, what kind of file it is opening. It will know from the file extension or It will open the file in binary and read the header of the file and then it i will create object of that File type.
Or any known methods of finding out the image file formats.
For above problem, how you design your system. Which are design patterns you will use.
Thanks in advance.
Harsha
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说应用程序的整体设计模式与图像格式识别的过程完全无关。
每种图像文件格式很早就具有二进制信息,指示文件的类型,即文件的“标头”。
例如,GIF 文件以字母 GIF 和指示 GIF 规范版本的代码 87a 或 89a 开头。 PNG 文件 - 正如 Robert Harvey 所指出的 - 有一个特殊字符,后跟 PNG 作为文件的前四个字节。
大多数主要图像格式的维基百科条目都解释了标头,以及有关文件本身的更多信息 - 除了上面涵盖 PNG 和 JPEG 的链接之外,还有 http://en.wikipedia.org/wiki/GIF#File_format 用于 GIF。
I would have said the design pattern of the application overall is completely unrelated to the process of image format recognition.
Each image file format has binary information very early on which indicate the type of file it is, which is the 'header' of the file.
GIF files, for example, begin with the letters GIF, and a code to indicate which version of the GIF specification, 87a or 89a. PNG files - as Robert Harvey indicates - have a special character, followed by PNG as the first four bytes of the file.
Most of the Wikipedia entries for the major image formats do explain the header, and a bit more about the file itself - in addition to the links above which cover PNG and JPEG, there's also http://en.wikipedia.org/wiki/GIF#File_format for GIFs.
假设我有一个扩展名为 .PNG 的文件,但我不确定它是否真的是 PNG 文件。我可以查看标题并验证它是否是 PNG 文件。
对于 JPG,我可以查看文件的语法和结构,看看它是否是我对 JPG 的期望是什么。
一般来说,算法是:假设图像文件就是文件扩展名所说的格式,直到文件的内部结构证明扩展名是错误的。
Let's say I have a file with the .PNG extension, and I'm not sure that it really is a PNG file. I can look at the header and verify that it is a PNG file.
For JPG's I can look at the syntax and structure of the file, and see if it is what I would expect from a JPG.
Generally speaking, the algorithm is: Assume that the image file is the format that the file extension says it is, until the internal structure of the file proves that the extension is wrong.