About BMP image files
Usually uncompressed, so a screenshot as BMP can be ten times the size of the same PNG. Browsers display it, but there is no reason to serve BMP on the web; convert it to PNG.
Other types seen for these files:
image/x-ms-bmp
. Accept them when reading uploads, but send image/bmp yourself.
File signature
BMP files start with 42 4D ("BM"). The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .bmp with the right Content-Type
Content-Type: image/bmp
image/bmp bmp dib;
AddType image/bmp .bmp .dib
@bmp path *.bmp *.dib
header @bmp Content-Type "image/bmp"
curl -sI https://example.com/file.bmp | grep -i '^content-type'
# Content-Type: image/bmp
Set the type in code
res.set('Content-Type', 'image/bmp');
// Or make the browser download it:
res.attachment('file.bmp');
import mimetypes
mimetypes.add_type('image/bmp', '.bmp') # if your system doesn't know it
mimetypes.guess_type('file.bmp')[0] # 'image/bmp'
mime.AddExtensionType(".bmp", "image/bmp")
w.Header().Set("Content-Type", "image/bmp")
Accept .bmp uploads
<input type="file" accept=".bmp,.dib,image/bmp">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
More images
.gif , .webp , .avif , .heic , .ico . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .bmp files?
image/bmp. You may also see image/x-ms-bmp, which is older or unofficial; send image/bmp. The full header is "Content-Type: image/bmp".
Why does my server send the wrong Content-Type for .bmp?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .bmp is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is BMP?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. BMP files start with 42 4D ("BM"). The MIME type lookup on this site reads them for you when you drop a file on it.