Mega Code Archive

 
Categories / Php / Graphics
 

Image Size and Mime Types

/* Image Information such as size and mime types can be returned with the getimagesize() function... here are a few useful examples */ <?php $size = getimagesize ("img/flag.jpg"); echo "<img src=\"img/flag.jpg\" {$size[3]}>"; ?> <?php $size = getimagesize ($filename); $fp=fopen($filename, "rb"); if ($size && $fp) { header("Content-type: {$size['mime']}"); fpassthru($fp); exit; } else { // error } ?> /* APP Info (embedded text information) */ <?php $size = getimagesize ("testimg.jpg",&$info); if (isset ($info["APP13"])) { $iptc = iptcparse ($info["APP13"]); var_dump ($iptc); } ?>