Open In App

PHP | GmagickPixel __construct() Function

Last Updated : 29 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
The GmagickPixel::__construct() function is an inbuilt function in PHP which is used to construct an GmagickPixel object. If a color is specified, the object is constructed and then initialized with that color before being returned. Syntax:
GmagickPixel GmagickPixel::__construct( string $color )
Parameters: This function accepts a single parameter $color which is optional and holds the color. Return Value: This function returns GmagickPixel object on success. Exceptions: This function throws GmagickPixelException on error. Below given programs illustrate the GmagickPixel::__construct() function in PHP: Program 1 (Without color parameter): php
<?php

// Create a new GmagickPixel
// object using __construct
$gmagickPixel = new GmagickPixel();

// Get the color
$color = $gmagickPixel->getcolor();
echo $color;
?>
Output:
rgb(0, 0, 0)
Program 2 (With color parameter): php
<?php

// Create a new GmagickPixel object
// using __construct
$gmagickPixel = new GmagickPixel('#ccb062');

// Get the color
$color = $gmagickPixel->getcolor();
echo $color;
?>
Output:
rgb(52428, 45232, 25186)
Reference: https://www.php.net/manual/en/gmagickpixel.construct.php

Next Article

Similar Reads