What is the image type for bmp?

Image type for png is image/x-png,

image type for gif is image/gif,

image type for jpg is image/jpeg or image/pjpeg.

But what is the image type for bmp? Is there somewhere that I can find the image type for all images?

Are you needing this for an upload form?

Yep.

Then you should not be using mime types.


function image_type ( $image )
{
  if ( function_exists( 'exif_imagetype' ) )
    return exif_imagetype( $image );
  
  $tmp = getimagesize( $image );
  return $tmp[2];
}

image_type( 'image.gif' ) === IMAGETYPE_GIF;
image_type( 'image.jpg' ) === IMAGETYPE_JPEG;
image_type( 'image.png' ) === IMAGETYPE_PNG;
image_type( 'image.bmp' ) === IMAGETYPE_BMP;

Note: If you are using GD I do not think it will work with bmp images.

Since bmp images can’t be displayed by web browsers it would make no sense whatever for any online processing to be able to generate them - you’d have to convert it to a gif, jpg, or png before being able to display it on a web page so why not generate it in one of those formats to start with.

The only web browser that can handle bmps is Internet Explorer and the only reason it can do that is because of something Microsoft tried to introduce into windows called an active desktop where the desktop could display dynamically generated data as if it were a web page and bmp support was included so that they could be used on dynamically generated desktops as wall as using them as static images. That idea failed to catch on but IE still supports bmps simply because of the module in the operating system that handles both web page rendering and active desktop.

I didn’t know that bmps can’t be displayed by other browsers! Thanks for the info.