Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 634
Joe Scotto Avatar asked Nov 13 '15 12:11

Joe Scotto


People also ask

Are JPG and JPEGs the same?

There are actually no differences between the JPG and JPEG formats. The only difference is the number of characters used. JPG only exists because they required a three-letter extension for the file names in earlier versions of Windows (MS-DOS 8.3 and FAT-16 file systems). So .

What type of image is JPG?

JPEG (Joint Photographic Experts Group image) JPEG is actually a data format for compressed photos, rather than a file type. The JFIF (JPEG File Interchange Format) specification describes the format of the files we think of as "JPEG" images.


2 Answers

No, image/jpg is not the same as image/jpeg.

You should use image/jpeg. Only image/jpeg is recognised as the actual mime type for JPEG files.

See https://www.rfc-editor.org/rfc/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.

like image 181
Adrian Baker Avatar answered Sep 30 '22 17:09

Adrian Baker


tl;dr the "standards" are a hodge-podge mess; it depends who you ask!

Overall, there appears to be no MIME type image/jpg. Yet, in practice, nearly all software handles image files named "*.jpg" just fine.
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. In other words, file name extension .jpg could be many different things.

For example, here are three "complete lists" and one RFC that with varying JPEG Image format file name extensions and the associated MIME types.

  • sitepoint.com mime-types-complete-list (archived)
    • .jfif, .jfif-tbnl, .jpe, .jpeg, .jpgimage/jpeg
    • .jfif, .jpe, .jpeg, .jpgimage/pjpeg
  • freeformatter.com mime-types (archived)
    • .jpeg, .jpgimage/jpeg
    • .jpeg, .jpgimage/x-citrix-jpeg
    • .pjpegimage/pjpeg
  • IANA "Media Types" (formerly known as MIME types) lists (archived)
    (this document lists "names", not "file name extensions")
    • jpg not mentioned
    • jpeg → see RFC 2045 (no mention), see RFC 2046image/jpeg13
    • JPEGvideo/JPEG
    • jpeg2000video/jpeg2000
    • jpmimage/jpm (JPEG 2000)
    • jpximage/jpx (JPEG 2000)
    • vnd.sealedmedia.softseal.jpgimage/vnd.sealedmedia.softseal.jpg
  • RFC 3745 MIME Type Registrations for JPEG 2000 (ISO/IEC 15444)
    • .jpg file extension not mentioned
    • .jpeg file extension not mentioned
    • .jp2, .jpg2image/jp2 (JPEG 2000)9
    • .jpf, .jpximage/jpx (JPEG 2000 ISO-JPEG2000-2 encoded image data)10
    • .mj2, .mjp2video/mj2 (Motion JPEG 2000)11
    • .jpm, .jpgmimage/jpm (JPEG 2000 profiles and extensions)12

These "complete lists" and RFC do not have MIME type image/jpg! But for MIME type image/jpeg some lists do have varying file name extensions (.jpeg, .jpg, …). Other lists do not mention image/jpeg.

Also, there are different types of JPEG Image formats (e.g. Progressive JPEG Image format, JPEG 2000, etcetera) and "JPEG Extensions" that may or may not overlap in file name extension and declared MIME type.

Another confusing thing is RFC 3745 does not appear to match IANA Media Types yet the same RFC is supposed to inform the IANA Media Types document. For example, in RFC 3745 .jpf is preferred file extension for image/jpx but in IANA Media Types the name jpf is not present (and that IANA document references RFC 3745!).

Another confusing thing is IANA Media Types lists "names" but does not list "file name extensions". This is on purpose, but confuses the endeavor of mapping file name extensions to MIME types.

Another confusing thing: is it "mime", or "MIME", or "MIME type", or "mime type", or "mime/type", or "media type"⁉ 😧


The most official seeming document by IANA is surprisingly inadequate. No MIME type is registered for file extension .jpg yet there exists the odd vnd.sealedmedia.softseal.jpg. File extension.JPEG is only known as a video type while file extension .jpeg is an image type (when did lowercase and uppercase letters start mattering!?). At the same time, jpeg2000 is type video yet RFC 3745 considers JPEG 2000 an image type! The IANA list seems to cater to company-specific jpeg formats (e.g. vnd.sealedmedia.softseal.jpg).


In summary...

Because of the prior confusions, it is difficult to find an industry-accepted canonical document that maps file name extensions to MIME types, particularly for the JPEG Image File Format.



Related question "List of ALL MimeTypes on the Planet, mapped to File Extensions?".

like image 40
JamesThomasMoon Avatar answered Sep 30 '22 15:09

JamesThomasMoon