You need to pass this function a colour:
<?php
$img->blackThresholdImage( "#FFFFFF" );
?>
E.g. this blackens any pixel which isn't pure white.(PECL imagick 2, PECL imagick 3)
Imagick::blackThresholdImage — Force tous les pixels en dessous d'un seuil à noir
Équivalent de la fonction Imagick::thresholdImage(), mais
force tous les pixels en dessous du seuil threshold
en noir, et laisse les autres pixels inchangés.
thresholdLe seuil en dessous duquel tout doit devenir noir
Retourne true en cas de succès.
| Version | Description |
|---|---|
| PECL imagick 2.1.0 | Permet désormais l'utilisation d'une chaîne pour représenter la couleur. Les versions précédentes ne permettaient que les objets ImagickPixel. |
Exemple #1 Exemple avec Imagick::blackThresholdImage()
<?php
function blackThresholdImage($imagePath, $thresholdColor) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->blackthresholdimage($thresholdColor);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>You need to pass this function a colour:
<?php
$img->blackThresholdImage( "#FFFFFF" );
?>
E.g. this blackens any pixel which isn't pure white.Here's a example of this function:
<?php
$img = new Imagick();
$img->readImage($image_file_name);
$img->blackThresholdImage('grey');
$img->writeImage($thumb_file_name);
$img->clear();
$img->destroy();
?>