PHP 8.3.4 Released!

Imagick::blackThresholdImage

(PECL imagick 2, PECL imagick 3)

Imagick::blackThresholdImageFuerza a todos los píxeles bajo un umbral a ser negros

Descripción

public Imagick::blackThresholdImage(mixed $threshold): bool

Es como Imagick::thresholdImage() pero fuerza a todos los píxeles bajo un umbral a ser negros mientras deja todos los píxeles por encima del umbral sin cambios.

Parámetros

threshold

El umbral por debajo del cual todo se vuelve de color negro

Valores devueltos

Devuelve true en caso de éxito.

Historial de cambios

Versión Descripción
PECL imagick 2.1.0 Ahora se permite que una cadena represente el color como un parámetro. Versiones anteriores sólo permitían un objeto ImagickPixel.

Ejemplos

Ejemplo #1 Imagick::blackThresholdImage()

<?php
function blackThresholdImage($imagePath, $thresholdColor) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->blackthresholdimage($thresholdColor);
header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();
}

?>

add a note

User Contributed Notes 2 notes

up
4
Iddles
12 years ago
You need to pass this function a colour:

<?php

$img
->blackThresholdImage( "#FFFFFF" );

?>

E.g. this blackens any pixel which isn't pure white.
up
1
elmer at web-axis dot net
15 years ago
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();
?>
To Top