PHPKonf Istanbul PHP Conference 2019 - Call for Papers


(PECL imagick 2.0.0)

Imagick::solarizeImageApplique un effet de solarisation à l'image


bool Imagick::solarizeImage ( int $threshold )

Applique un effet de solarisation à l'image, similaire à l'effet effectué dans une chambre noire en exposant des zones du papier photo sensitive à la lumière. Le seuil threshold peut aller de 0 à QuantumRange et mesure la densité de la solarisation.

Liste de paramètres


Valeurs de retour

Retourne TRUE en cas de succès.


Exemple #1 Exemple avec Imagick::solarizeImage()

function solarizeImage($imagePath$solarizeThreshold) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->solarizeImage($solarizeThreshold * \Imagick::getQuantum());
header("Content-Type: image/jpg");


add a note add a note

User Contributed Notes 1 note

holdoffhunger at gmail dot com
6 years ago
This is something neat that you can do to an image as part of making it artistic, probably in conjunction with other ImageMagick effects, like PosterizeImage and OilPaintImage.  SolarizeImage shifts the whole color spectrum toward red for an image -- white gets pushed directly into red, blues get pushed into greens, etc..  It is mostly a psychedelic effect.  You have the option of choosing one parameter for "Threshold", which is really simply how much of this effect you want to have in an image.  The minimum value is 0, and using a negative number defaults it to 0.  The maximum value is the Quantum Threshold.  You can get this value by the ImageMagick function getQuantumRange.  On my install of PHP, that value is set to 65535 (2^16).  Going higher than the Quantum Range defaults to the Quantum Range.  An image with this function performed on it at Threshold 0 has the maximum effect performed, and at Threshold maximum the image has no changes made to it at all.

And now a simple demonstration of the code :


// Author:

        // Grab Image File Data
        // ---------------------------------------------
$file_to_grab_with_location = "graphics_engine/image_workshop_directory/test.bmp";
$imagick_type = new Imagick();
// Open File
        // ---------------------------------------------
$file_handle_for_viewing_image_file = fopen($file_to_grab_with_location, 'a+');

// Perform Function
        // ---------------------------------------------
// Filename
        // ---------------------------------------------
$file_to_save_with_location = "graphics_engine/image_workshop_directory/test_new.bmp";
// Save File
        // ---------------------------------------------
$file_handle_for_saving_image_file = fopen($file_to_save_with_location, 'a+');


To Top