php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62681 mime_content_type gets wrong mime
Submitted: 2012-07-28 09:42 UTC Modified: 2021-08-16 12:57 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: BenjaminBeck at gmx dot de Assigned: cmb (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.3.15 OS: ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 9 = ?
Subscribe to this entry?

 
 [2012-07-28 09:42 UTC] BenjaminBeck at gmx dot de
Description:
------------
PHP function "mime_content_type" returns wrong mime type:
"application/octet-stream" instead of "image/jpeg" on a jpg image.
I checked the magic bytes (jpeg header) of the file with a hex editor and it 
looked fine to me.

the image is taken by a smartfone (HTC 7 Mozart T8698).

this is the image:
http://dl.dropbox.com/u/25310351/7.jpeg



Test script:
---------------
$res = mime_content_type("7.jpg");
var_dump($res);

Expected result:
----------------
image/jpeg

Actual result:
--------------
application/octet-stream

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-28 09:44 UTC] BenjaminBeck at gmx dot de
my system configuration which produced the bug is:
PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch (cli) (built: Feb 11 2012 03:26:01) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
 [2012-07-28 14:14 UTC] rasmus@php.net
This is because your picture is not standard JPEG/JFIF but instead JPEG/EXIF. 
The command-line Linux 'file' program doesn't understand it either:

7:03am x220:~> file 7.jpeg
7.jpeg: Claris clip art?

You can get it using:

var_dump(image_type_to_mime_type(exif_imagetype("7.jpeg")))

which produces: image/jpeg

But yes, we should support non-JFIF jpeg files as well here.
 [2012-07-28 14:14 UTC] rasmus@php.net
-Status: Open +Status: Analyzed
 [2018-04-03 13:09 UTC] cmb@php.net
-Package: *Graphics related +Package: Unknown/Other Function
 [2021-08-16 12:57 UTC] cmb@php.net
-Status: Analyzed +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-08-16 12:57 UTC] cmb@php.net
If this issue still persists, please report it upstream[1].

[1] <https://www.darwinsys.com/file/>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 13:01:30 2024 UTC