php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77990 The mime should be image/x-ms-bmp, not image/bmp in getimagesize function
Submitted: 2019-05-08 08:55 UTC Modified: 2019-05-08 09:32 UTC
From: peter279k at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: GetImageSize related
PHP Version: 7.3.5 OS: Ubuntu 16.04.6 LTS
Private report: No CVE-ID: None
 [2019-05-08 08:55 UTC] peter279k at gmail dot com
Description:
------------
The getimagesize function mime result should be enhanced.

The mime content type should be image/x-ms-bmp, not image/bmp.

Test script:
---------------
<?php

echo mime_content_type('php.bmp') . "\n";
echo getimagesize('php.bmp')['mime'] . "\n";

Expected result:
----------------
image/x-ms-bmp
image/x-ms-bmp

Actual result:
--------------
image/x-ms-bmp
image/bmp

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-08 09:11 UTC] spam2 at rhsoft dot net
no, it should not because the x/- stuff is temporary / not standarized

https://en.wikipedia.org/wiki/BMP_file_format
Internet media type image/bmp, image/x-bmp
 [2019-05-08 09:18 UTC] peter279k at gmail dot com
I wonder why the mime content type has different result for mime_content_type and getimagesize functions?
 [2019-05-08 09:21 UTC] spam2 at rhsoft dot net
because https://www.php.net/manual/en/function.mime-content-type.php is part of the fileinfo extension and https://www.php.net/manual/en/function.getimagesize.php is part of the gd extension which are completly different worlds
 [2019-05-08 09:28 UTC] peter279k at gmail dot com
To spam2@rhsoft.net, according to the wiki you provide, it seems that the BMP has two internet mime content type.

They will be image/bmp, or image/x-bmp.

Shouldn't we consider/concern this?

And make this consistency or add some messages on official PHP doc?
 [2019-05-08 09:30 UTC] spam2 at rhsoft dot net
PHP does nothing here, it calls libraries and depending on the library version you get the old x- stuff or the finalized mime-type - you are supposed to know the valid results in your code and test against both
 [2019-05-08 09:32 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: Output Control +Package: GetImageSize related -Assigned To: +Assigned To: cmb
 [2019-05-08 09:32 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The change to getimagesize() is documented in the migration
guide[1].  The fact that mime_content_type() still returns the
obsolete mime type should be reported against upstream[2].

[1] <https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.misc>
[2] <http://www.darwinsys.com/file/>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC