The Imagick::newImage() function is an inbuilt function in PHP which is used to creates a new image. This function creates a new image and associates ImagickPixel value as the background color.
Syntax:
bool Imagick::newImage( $cols, $rows, $background, $format )
Parameters: This function accepts four parameters as mentioned above and described below:
- $cols: This parameter is used to set the column of image.
- $rows: This parameter is used to set the row of image.
- $background: This parameter is used to set the background color of image.
- $format: This parameter is used to define the image format.
Return Value: This function returns True on success.
Errors/Exceptions: This function throws ImagickException on error.
Below program illustrates the Imagick::newImage() function in PHP:
Program:
<?php // Create an Imagick object $image = new Imagick(); // Use newImage function to creae new image $image->newImage(650, 400, new ImagickPixel('green')); // Set the image format $image->setImageFormat('png'); header('Content-type: image/png'); // Display the output image echo $image; ?> |
Output:

Reference: http://php.net/manual/en/imagick.newimage.php
Recommended Posts:
- PHP | Imagick floodFillPaintImage() Function
- PHP | Imagick adaptiveSharpenImage() Function
- PHP | Imagick flopImage() Function
- PHP | Imagick setImageExtent() Function
- PHP | Imagick getImageWhitePoint() Function
- PHP | Imagick getCompressionQuality() Function
- PHP | Imagick clear() Function
- PHP | Imagick annotateImage() Function
- PHP | Imagick adaptiveResizeImage() Function
- PHP | Imagick adaptiveBlurImage() Function
- PHP | Imagick adaptiveThresholdImage() Function
- PHP | Imagick addNoiseImage() Function
- PHP | Imagick colorizeImage() Function
- PHP | Imagick addImage() Function
- PHP | Imagick setImageDispose() Function
- PHP | Imagick borderImage() Function
- PHP | Imagick getImageMatte() Function
- PHP | Imagick getImageMimeType() Function
- PHP | Imagick getImageRenderingIntent() Function
- PHP | imagick getImageDispose() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

