Graphics

Changed MIME type for getimagesize()

Even without any extensions like gd or imagemagick, PHP can provide you with information about images:

var_dump(getimagesize('/path/to/image.jpg'));

The result is an array, including, among other things, the MIME type of the image:

array(7) {
  [0]=>
  int(1024)
  [1]=>
  int(683)
  [2]=>
  int(2)
  [3]=>
  string(25) "width="1024" height="683""
  ["bits"]=>
  int(8)
  ["channels"]=>
  int(3)
  ["mime"]=>
  string(10) "image/jpeg"
}

If you happen to work with bitmaps, you need to know that their MIME type used to be reported as image/x-ms-bmp, but will be reported as image/bmp as of PHP 7.3. Indeed, Microsoft has registered the Windows Image Media Types with IANA.

If your application relies on the verbatim MIME type and potentially has to deal with bitmaps, consider introducing a wrapper function, or make sure the behaviour of your application does not change when another MIME type is returned.