function thumbnailImage($image_path) { $imagick = new \Imagick(realpath($image_path)); $imagick->setbackgroundcolor('rgb(64, 64, 64)'); $imagick->thumbnailImage(100, 100, true, true); header("Content-Type: image/jpeg"); echo $imagick->getImageBlob(); }