Re: Re: how to detect type of image
| From: | Tijnema ! | Date: | Sat, 28 Apr 2007 14:33:18 +0000 |
| Subject: | Re: Re: how to detect type of image | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254060@lists.php.net to get a copy of this message | ||
On 4/28/07, Edward Vermillion <evermillion@doggydoo.net> wrote:
On Apr 28, 2007, at 6:54 AM, tedd wrote: At 2:10 AM +0200 4/28/07, Tim wrote:Did you read the line just above example 935? " mime is the correspondant MIME type of the image. This information can be used to deliver images with correct the HTTP Content-type header: " TijnemaTim: It should, but instead try this: $image_size = getimagesize($filename); echo $image_size['mime']; $image_size['mime'] ? Where did that come from? From the manual: "Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants that were added in PHP 4.3.0. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag." So it should be $image_size[2], or has something changed that I don't know about? EdOn 21.04.2007 12:45, Alain Roger wrote:Hi, In my web application, end user is able to load images (png, jpeg, gif,..) into database. I would like to know how can i detect automatically the type of image (pnd, jpeg,...) ? i do not want to check the extension because this is easily faked... just by renaming it. Does it exist a technique for that ? thanks a lot,Hi, unfortunately mime_content_type() does not work for me.