Content type html jpg

Common MIME types

This topic lists the most common MIME types with corresponding document types, ordered by their common extensions.

The following two important MIME types are the default types:

  • text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data.
  • application/octet-stream is the default value for all other cases. An unknown file type should use this type. Browsers are particularly careful when manipulating these files to protect users from software vulnerabilities and possible dangerous behavior.

IANA is the official registry of MIME media types and maintains a list of all the official MIME types. This table lists important MIME types for the Web:

Extension Kind of document MIME Type
.aac AAC audio audio/aac
.abw AbiWord document application/x-abiword
.arc Archive document (multiple files embedded) application/x-freearc
.avif AVIF image image/avif
.avi AVI: Audio Video Interleave video/x-msvideo
.azw Amazon Kindle eBook format application/vnd.amazon.ebook
.bin Any kind of binary data application/octet-stream
.bmp Windows OS/2 Bitmap Graphics image/bmp
.bz BZip archive application/x-bzip
.bz2 BZip2 archive application/x-bzip2
.cda CD audio application/x-cdf
.csh C-Shell script application/x-csh
.css Cascading Style Sheets (CSS) text/css
.csv Comma-separated values (CSV) text/csv
.doc Microsoft Word application/msword
.docx Microsoft Word (OpenXML) application/vnd.openxmlformats-officedocument.wordprocessingml.document
.eot MS Embedded OpenType fonts application/vnd.ms-fontobject
.epub Electronic publication (EPUB) application/epub+zip
.gz GZip Compressed Archive application/gzip
.gif Graphics Interchange Format (GIF) image/gif
.htm , .html HyperText Markup Language (HTML) text/html
.ico Icon format image/vnd.microsoft.icon
.ics iCalendar format text/calendar
.jar Java Archive (JAR) application/java-archive
.jpeg , .jpg JPEG images image/jpeg
.js JavaScript text/javascript (Specifications: HTML and RFC 9239)
.json JSON format application/json
.jsonld JSON-LD format application/ld+json
.mid , .midi Musical Instrument Digital Interface (MIDI) audio/midi , audio/x-midi
.mjs JavaScript module text/javascript
.mp3 MP3 audio audio/mpeg
.mp4 MP4 video video/mp4
.mpeg MPEG Video video/mpeg
.mpkg Apple Installer Package application/vnd.apple.installer+xml
.odp OpenDocument presentation document application/vnd.oasis.opendocument.presentation
.ods OpenDocument spreadsheet document application/vnd.oasis.opendocument.spreadsheet
.odt OpenDocument text document application/vnd.oasis.opendocument.text
.oga OGG audio audio/ogg
.ogv OGG video video/ogg
.ogx OGG application/ogg
.opus Opus audio audio/opus
.otf OpenType font font/otf
.png Portable Network Graphics image/png
.pdf Adobe Portable Document Format (PDF) application/pdf
.php Hypertext Preprocessor (Personal Home Page) application/x-httpd-php
.ppt Microsoft PowerPoint application/vnd.ms-powerpoint
.pptx Microsoft PowerPoint (OpenXML) application/vnd.openxmlformats-officedocument.presentationml.presentation
.rar RAR archive application/vnd.rar
.rtf Rich Text Format (RTF) application/rtf
.sh Bourne shell script application/x-sh
.svg Scalable Vector Graphics (SVG) image/svg+xml
.tar Tape Archive (TAR) application/x-tar
.tif , .tiff Tagged Image File Format (TIFF) image/tiff
.ts MPEG transport stream video/mp2t
.ttf TrueType Font font/ttf
.txt Text, (generally ASCII or ISO 8859-n) text/plain
.vsd Microsoft Visio application/vnd.visio
.wav Waveform Audio Format audio/wav
.weba WEBM audio audio/webm
.webm WEBM video video/webm
.webp WEBP image image/webp
.woff Web Open Font Format (WOFF) font/woff
.woff2 Web Open Font Format (WOFF) font/woff2
.xhtml XHTML application/xhtml+xml
.xls Microsoft Excel application/vnd.ms-excel
.xlsx Microsoft Excel (OpenXML) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xml XML application/xml is recommended as of RFC 7303 (section 4.1), but text/xml is still used sometimes. You can assign a specific MIME type to a file with .xml extension depending on how its contents are meant to be interpreted. For instance, an Atom feed is application/atom+xml , but application/xml serves as a valid default.
.xul XUL application/vnd.mozilla.xul+xml
.zip ZIP archive application/zip
.3gp 3GPP audio/video container video/3gpp ; audio/3gpp if it doesn’t contain video
.3g2 3GPP2 audio/video container video/3gpp2 ; audio/3gpp2 if it doesn’t contain video
.7z 7-zip archive application/x-7z-compressed
Читайте также:  Python requests error 500

Found a content problem with this page?

This page was last modified on Apr 10, 2023 by MDN contributors.

Источник

The .jpg and .jpeg Mime Type

Tutorial on delivering jpeg files with the correct mime type and headers using PHP.

JPEG and JPG mime type, PHP

The correct content-type to use for delivering jpeg image files over the HTTP protocol is image/jpeg. The standard file extension for jpeg images is .jpeg, but .jpg is also broadly supported.

A HTTP response to deliver a jpeg image can look like this:

HTTP/1.1 200 OK content-type: image/jpeg content-length: 39354 

Note. A character-set is not needed for image files.

To use the image/jpeg Mime Type from a PHP script, use the header function:

header('content-type: image/jpeg'); // Body output after this point 

Deliver JPEG files from PHP

Reading a local file into a variable can be done using file_get_contents, but this is impractical for larger files. After reading the content of a file, you can output it with echo.

While this below example works, there are many potential issues depending on the circumstances, so you should not use this without taking additional steps:

// Path to file $file_path = '/var/www/test.jpeg'; // Obtain file size for the content-length header $file_size = filesize($file_path); // Read the content from the file $jpeg_file = file_get_contents($file_path); header('content-length: ' . $file_size); header('content-type: image/jpeg'); echo $jpeg_file; 

JPEG vs JPG

The .jpg and .jpeg are both jpeg image files. The original extension used was .jpeg, but early Windows versions used .jpg, and many now prefer the 3 letter file extension as a result.

Browsers will accept the image/jpeg Mime Type for both file types. The image/jpg Mime Type does not exist.

Instead of using jpeg images, you may want to consider using the new webp format, as it offers better compression.

Editing JPEG files

You can edit .jpeg files using an editor such as Gimp or Paint.NET.

Gimp works well in both Windows and Linux, check gimp.org for the latest version.

Paint.NET works best in Windows, find it here: getpaint.net.

Источник

Оцените статью