cache($file,$h,$y)){ return $cached; } // store locally $localfile=$this->temp_path.md5($file); file_put_contents($localfile, file_get_contents($file)); // page selection - default to page 0, or passed param 'page' if(stristr($file,'.pdf')){ if(!@$_REQUEST['page']) $_REQUEST['page']=0; $page="[{$_REQUEST['page']}]"; } else{ $page=''; } try{ $thumbnail = new imagick("{$localfile}{$page}"); if($thumbnail){ $thumbnail->thumbnailImage($h,$y,true); $thumbnail->setImageFormat("png"); $this->cache($file,$h,$y,$thumbnail); return $thumbnail; } } catch(Exception $e){ // print/return the placeholder } } function displayThumbnail($data){ header('Content-type: image/png'); print $data; die(); } /** * * @desc * @author Leo Brown * @date May 24th 2010 * */ function cache($file,$h,$y,$data=null){ if($data){ // cache it } return false; } } if($file=@$_REQUEST['file']){ // default and requested sizes $h=175; $w=150; if($size=@$_REQUEST['size']){ $dims=explode('x',$size); if($width=reset($dims)) $w=$width; if($height=end($dims)) $h=$height; } $t=new Thumbnailer(); $thumb = $t->getThumbnail($file,$w,$h); $t->displayThumbnail($thumb); } ?>