- if (!function_exists("imagick_readimage")) { echo "Imagick-Extention nicht installiert"; return false; };
- $handle=imagick_readimage("./tmp/tmp.file_org");
- if (!$handle) {
- $reason = imagick_failedreason( $handle ) ;
- print "Lesen: $reason<BR>\n" ; flush();
- return false;
- }
- if (!imagick_resize( $handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) {
- $reason = imagick_failedreason( $handle ) ;
- print "Resize: $reason<BR>\n" ; flush();
- return false;
- }
- if (!imagick_writeimage( $handle,"./tmp/tmp.file_$dest")) {
- $reason = imagick_failedreason( $handle ) ;
- print "Schreiben: $reason<BR>\n" ; flush();
- return false;
- }
- return true;
+ if (!class_exists("Imagick")) { echo "Imagick-Extention nicht installiert"; return false; };
+ $handle= new Imagick();
+ if (!$handle->readImage("./tmp/tmp.file_org")) return false;
+ $d = $handle->getImageGeometry();
+ if ($d["width"]<$d["height"]) {
+ $f = $d["width"]/$d["height"];
+ $w = floor($width*$f);
+ $h = $height;
+ } else {
+ $f = $d["height"]/$d["width"];
+ $w = $width;
+ $h = floor($height*$f);
+ }
+ $handle->thumbnailImage( $w, $h);
+ return $handle->writeImage( "./tmp/tmp.file_$dest");