array("width"=>800,"height"=>600), "small"=>array("width"=>160,"height"=>120) ); if (array_key_exists("id",$_GET)) { if (array_key_exists('size',$_GET)){ $size=$_GET['size']; } else { $size = "original"; } if (!array_key_exists($size, $sizes) || strcmp("original", $size)==0){ $size = null; } $img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id'])); if (!is_null($img)){ $basepath = GlobalVariables::get("config")->paths->media; $toMime = $basepath."/".$img->id.".".$img->extension; $thumb = new Imagick($basepath."/".$img->id.".".$img->extension); $geom = $thumb->getimagegeometry(); if($img->extension != "gif"){ if (!is_null($size)){ if ($geom["width"]>=$geom["height"]){ $thumb->scaleimage($sizes[$size]["width"], 0,false); } else { $thumb->scaleimage(0, $sizes[$size]["height"],false); } } header('Content-type: '.mime_content_type($toMime)); echo $thumb; } else{ $thumb = $thumb->coalesceimages(); if (!is_null($size)){ foreach ($thumb as $frame){ if ($geom["width"]>=$geom["height"]){ $thumb->scaleimage($sizes[$size]["width"], 0,false); } else { $thumb->scaleimage(0, $sizes[$size]["height"],false); } } } $thumb = $thumb->deconstructimages(); header('Content-type: '.mime_content_type($toMime)); echo $thumb->getimagesblob(); } } } ?>