Re: Re: how to detect type of image
| From: | tedd | Date: | Sun, 29 Apr 2007 19:03:03 +0000 |
| Subject: | Re: Re: how to detect type of image | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254112@lists.php.net to get a copy of this message | ||
At 9:53 AM -0500 4/29/07, Edward Vermillion wrote:
On Apr 29, 2007, at 8:03 AM, tedd wrote:It was designed to provide information. As I said you use it as you want. Index 3 could have been used in and image tag, or in a report of the image -- whatever you can find a use for it, use it. The above example uses 'mime' for a header, but the below code uses it more directly. http://sperling.com/a/image_data/ Whatever floats your boat. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.comThe php functions that provide data about files, do just that. They inspect the header of the file and report what they have found. How you use them, is your business.Well, from the example it looks like that's returning a string that can go straight into the header() function... <?php $size = getimagesize($filename); $fp=fopen($filename, "rb"); if ($size && $fp) { header("Content-type: {$size['mime']}"); fpassthru($fp); exit; } else { // error } ?> whereas index 2 in the array returns an integer that corresponds to the IMAGETYPE_* constants. I would assume they both get the information from the same place, but just return it in different formats based on the intended usage. Just like index 3 will get you a string of 'width=? height=?' to add to an image tag, while index 0 and 1 returns an integer of width and height respectively. I can get the width and height from index 3, but that's not what it was designed for.