function whiteThresholdImage($imagePath, $color) { $imagick = new \Imagick(realpath($imagePath)); $imagick->whiteThresholdImage($color); header("Content-Type: image/jpg"); echo $imagick->getImageBlob(); }