图像处理应用程序如何识别用户打开的文件?

发布于 2024-10-04 18:50:32 字数 231 浏览 1 评论 0原文

图像处理应用程序如何识别用户打开的文件?

众所周知,图像处理应用程序可以打开所有已知的图像格式。我的问题是,图像处理应用程序如何知道它正在打开什么类型的文件。它将从文件扩展名中得知,或者它将以二进制方式打开文件并读取文件头,然后我将创建该文件类型的对象。

或任何已知的查找图像文件格式的方法。

对于上述问题,你如何设计你的系统。您将使用哪些设计模式。

提前致谢。

戒日

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

叹沉浮 2024-10-11 18:50:32

我想说应用程序的整体设计模式与图像格式识别的过程完全无关。

每种图像文件格式很早就具有二进制信息,指示文件的类型,即文件的“标头”。

例如,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.

小草泠泠 2024-10-11 18:50:32

假设我有一个扩展名为 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文