本文翻译自:Is the MIME type 'image/jpg' the same as 'image/jpeg'?
Pretty simple question but can't seem to find it anywhere online. 很简单的问题,但似乎无法在网上找到它。 I'm trying to make a program that depending on the file type will give me the extension. 我正在尝试制作一个程序,该程序根据文件类型为我提供扩展名。
#1楼
参考:https://stackoom.com/question/2hn2P/MIME类型-image-jpg-是否与-image-jpeg-相同
#2楼
No, image/jpg
is not the same as image/jpeg
, only image/jpeg
is recognised as the actual mime type for JPEG files. 不, image/jpg
与image/jpeg
,只有image/jpeg
被识别为JPEG文件的实际mime类型。
See https://tools.ietf.org/html/rfc3745 , https://www.w3.org/Graphics/JPEG/ . 见https://tools.ietf.org/html/rfc3745 , https://www.w3.org/Graphics/JPEG/ 。
Serving the incorrect Content-Type of image/jpg
to IE can cause issues, see http://www.bennadel.com/blog/2609-internet-explorer-aborts-images-with-the-wrong-mime-type.htm . 向IE提供不正确的Content / Type的image/jpg
内容类型可能会导致问题,请参见http://www.bennadel.com/blog/2609-internet-explorer-aborts-images-with-the-wrong-mime-type.htm 。
#3楼
For those it might help, I use this list as a reference to define my content-type when I have to deal with images on my app. 对于那些可能会有所帮助的应用程序,当我必须处理应用程序上的图像时,可以使用此列表作为定义内容类型的参考。
It says that jpg extension can be declared with Content-type : image/jpeg
它说jpg扩展名可以用Content-type : image/jpeg
声明Content-type : image/jpeg
There isn't any image/jpg
attribute for content-type. 内容类型没有任何image/jpg
属性。
#4楼
tl;dr it depends who you ask tl; dr 这取决于您问的是谁
Overall, there appears to be no MIME type image/jpg
. 总体而言,似乎没有MIME类型image/jpg
。 Yet, in practice, nearly all software handles image files named " *.jpg
" just fine. 然而,实际上,几乎所有软件都可以处理名为“ *.jpg
”的图像文件。 This particular topic is confusing because the varying association of file name extension associated to a MIME type depends which organization created the table of file name extensions to MIME types. 该特定主题令人困惑,因为与MIME类型相关联的文件扩展名的不同关联取决于哪个组织创建了MIME类型的文件扩展名表。 In other words, file name extension .jpg
could be many different things. 换句话说,文件扩展名.jpg
可能有很多不同的东西。
For example, here are 3 "complete lists" that vary around various JPEG Image format file name extensions and the associated MIME types. 例如,这里有3个“完整列表”,它们围绕各种JPEG图像格式文件扩展名和相关的MIME类型而变化。
- sitepoint.com mime-types-complete-list ( archived ) sitepoint.com mime-types-complete-list ( 已存档 )
-
.jfif
,.jfif-tbnl
,.jpe
,.jpeg
,.jpg
→image/jpeg
.jfif
,.jfif-tbnl
,.jpe
,.jpeg
,.jpg
→image/jpeg
-
.jfif
,.jpe
,.jpeg
,.jpg
→image/pjpeg
.jfif
,.jpe
,.jpeg
,.jpg
→image/pjpeg
-
- freeformatter.com mime-types ( archived ) freeformatter.com MIME类型 ( 已存档 )
-
.jpeg
,.jpg
→image/jpeg
.jpeg
,.jpg
→image/jpeg
-
.jpeg
,.jpg
→image/x-citrix-jpeg
.jpeg
,.jpg
→image/x-citrix-jpeg
-
.pjpeg
→image/pjpeg
.pjpeg
→image/pjpeg
-
- IANA "Media Types" (formerly known as MIME types) lists ( archived ) IANA“媒体类型”(以前称为MIME类型)列表( 已存档 )
-
.jpeg
→ (nothing).jpeg
→(什么都没有) -
.JPEG
→video/JPEG
.JPEG
→video/JPEG
-
.jpm
→image/jpm
(refers to JPEG 2000).jpm
→image/jpm
(指JPEG 2000) -
.jpx
→image/jpx
(refers to JPEG 2000).jpx
→image/jpx
(指JPEG 2000) -
vnd.sealedmedia.softseal.jpg
→image/vnd.sealedmedia.softseal.jpg
😖vnd.sealedmedia.softseal.jpg
→image/vnd.sealedmedia.softseal.jpg
/vnd.sealedmedia.softseal.jpg😖
-
These "complete lists" do not have MIME type image/jpg
! 这些“完整列表”没有MIME类型image/jpg
! But for MIME type image/jpeg
these lists do have varying file name extensions ( .jpeg
, .jpg
, …). 但是对于MIME类型image/jpeg
这些列表确实具有不同的文件扩展名( .jpeg
, .jpg
…)。
Also, there are different types of JPEG Image format s (eg Progressive JPEG Image format , JPEG 2000 , etcetera) that may or may not overlap in file name extension and declared MIME type. 另外,还有不同类型的JPEG图像格式 (例如, 渐进式JPEG图像格式 , JPEG 2000等),它们在文件扩展名和声明的MIME类型中可能重叠也可能不重叠。 This adds to the overall confusion. 这增加了整体混乱。
Another confusing thing: is it " mime ", or " MIME ", or " MIME type ", or " mime type ", or " mime/type ", or " media type "⁉ 😧 另一个令人困惑的事情是:“ mime ”,“ MIME ”,“ MIME类型 ”,“ mime类型 ”,“ mime / type ”或“ 媒体类型 ”⁉
It appears that several organizations publish their own file extension and MIME type mapping document ("complete lists"). 似乎有几个组织发布了自己的文件扩展名和MIME类型映射文档(“完整列表”)。
The most official seeming document by IANA is surprisingly inadequate; 令人惊讶的是,IANA 出具的最正式文件似乎不足。 nothing is registered for an image type .jpeg
, and .JPEG
is only known as video type. .jpeg
图像类型未注册任何内容, .JPEG
仅被称为视频类型。 The IANA list seems to cater to company-specific jpeg formats (eg vnd.sealedmedia.softseal.jpg
). IANA列表似乎适合公司特定的jpeg格式(例如vnd.sealedmedia.softseal.jpg
)。
Because of the prior, it is difficult to find an industry-accepted canonical document for reference. 由于先前的原因,很难找到行业认可的规范文档以供参考。
Related question " List of ALL MimeTypes on the Planet, mapped to File Extensions? ". 相关问题“ 映射到文件扩展名的星球上所有MimeType的列表? ”。
#5楼
The important thing to note here is that the mime type is not the same as the file extension. 这里要注意的重要一点是,MIME类型是不一样的文件扩展名。 Sometimes, however, they have the same value. 但是,有时它们具有相同的价值。
https://www.iana.org/assignments/media-types/media-types.xhtml includes a list of registered Mime types, though there is nothing stopping you from making up your own, as long as you are at both the sending and the receiving end. https://www.iana.org/assignments/media-types/media-types.xhtml包含已注册的Mime类型的列表,尽管没有什么阻止您组成自己的Mime,只要您同时处于发送状态即可和接收端。 Here is where Microsoft comes in to the picture. 这是Microsoft出现的地方。
Where there is a lot of confusion is the fact that operating systems have their own way of identifying file types by using the tail end of the file name, referred to as the extension. 造成混乱的地方是,操作系统通过使用文件名的尾部(称为扩展名)来标识文件类型。 I modern operating systems, the whole name is one long string, but in more primitive operating systems, it is treated as a separate attribute. 在现代操作系统中,全名是一个长字符串,但是在更原始的操作系统中,它被视为单独的属性。
The OS which caused the confusion is MSDOS, which had limited the extension to 3 characters. 引起混乱的操作系统是MSDOS,它已将扩展名限制为3个字符。 This limitation is inherited to this day in devices, such as SD cards, which still store data in the same way. 迄今为止,这种限制已在仍以相同方式存储数据的设备(例如SD卡)中继承。
One side effect of this limitation is that some file extensions, such as .gif
match their Mime Type, image/gif
, while others are compromised. 此限制的副作用是某些文件扩展名(例如.gif
与它们的Mime类型匹配,即image/gif
,而其他文件扩展名则受到了威胁。 This includes image/jpeg
whose extension is shortened to .jpg
. 这包括image/jpeg
其扩展名缩短为.jpg
。 Even in modern Windows, where the limitation is lifted, Microsoft never let the past go, and so the file extension is still the shortened version. 即使在解除限制的现代Windows中,Microsoft也永远不会过去,因此文件扩展名仍然是简化版本。
Given that that: 鉴于此:
- File Extensions are not File Types 文件扩展名不是文件类型
- Historically, some operating systems had serious file name limitations 历史上,某些操作系统存在严重的文件名限制
- Some operating systems will just go ahead and make up their own rules 某些操作系统只会继续制定自己的规则
The short answer is: 简短的答案是:
- Technically, there is no such thing as
image/jpg
, so the answer is that it is not the same asimage/jpeg
从技术上讲,没有image/jpg
类的东西,因此答案是它与image/jpeg
- That won't stop some operating systems and software from treating it as if it is the same 这不会阻止某些操作系统和软件将其视为相同