Related Articles

Related Articles

PHP | GmagickPixel __construct() Function
  • Last Updated : 29 Jan, 2020

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):

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new GmagickPixel
// object using __construct
$gmagickPixel = new GmagickPixel();
  
// Get the color
$color = $gmagickPixel->getcolor();
echo $color;
?>

chevron_right


Output:

rgb(0, 0, 0)

Program 2 (With color parameter):

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new GmagickPixel object
// using __construct
$gmagickPixel = new GmagickPixel('#ccb062');
  
// Get the color
$color = $gmagickPixel->getcolor();
echo $color;
?>

chevron_right


Output:

rgb(52428, 45232, 25186)

Reference: https://www.php.net/manual/en/gmagickpixel.construct.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :