Change language

PHP Imagick transparentPaintImage () function

Syntax:
bool Imagick::transparentPaintImage (mixed $target, float $alpha, float $fuzz, bool $invert)
Parameters:This function takes four parameters as above and described below:
  • $target:target color for drawing transparent.
  • $alpha:transparency range: 1.0 is fully opaque and 0.0 is fully transparent.
  • $fuzz:if TRUE paints any pixel that does not match the target color.
  • $invert:whitePoint image.
    Return value: this function returns Trueon success.
The following program illustrates the Imagick::transparentPaintImage() function in PHP:Example: // $source = & quot; gfg_350X350.png & quot ;; $source = " https://media.engineerforengineer.org/wp-content/uploads/20190809013546/gfg_350X350.png " ; $target = "transpaintimg.png " ; $color = "rgb (39 , 194, 255) " ; $alpha = "0.5" ; $fuzz = "0.1" ; $inverse = "normal" ; $imagick = new Imagick ( realpath ( $source )); // Must be in a format that supports transparency $imagick -> setimageformat ( ’png’ ); $imagick -> transparentPaintImage ( $color , $alpha , $fuzz * Imagick::getQuantum(), $inverse ); // Not required, but helps to remove the remaining pixels $imagick -> despeckleimage(); $canvas = new Imagick(); $canvas -> newPseudoImage ( $imagick -> getImageWidth(), $imagick -> getImageHeight(), "pattern: checkerboard" ); $canvas -> compositeimage ( $imagick , Imagick: : COMPOSITE_ATOP, 0, 0); $canvas -> setImageFormat ( ’png’ ); header ( " Content-Type: image / png " ); echo $canvas -> getImageBlob(); $canvas -> WriteImage ( $target ); ?> Output: Link: https://www.php.net/manual/en/imagick.transparentpaintimage.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method