function statisticImage($image_path, $statisticType, $width, $height, $channel) { $imagick = new \Imagick(realpath($image_path)); $imagick->statisticImage( $statisticType, $width, $height, $channel ); header("Content-Type: image/jpeg"); echo $imagick->getImageBlob(); }