Flood Fill to Specific Color in PHP Using imagefilltoborder GD Function

Urmila Samariya
Updated on 09-Aug-2021 11:56:33

389 Views

imagefilltoborder() is an inbuilt function in PHP that is used to perform flood fill with a specific color, whose border color is defined by the border. The starting point for the fill is (x, y) or top left is (0, 0) and the region is filled with the color.Syntaxbool imagefilltoborder(resource $image, int $x, int $y, int $border, int $color)Parametersimagefilltoborder() takes five different parameters: $image, $x, $y, $border, and $color.$image − It is the image resource.$x − Specifies the x-coordinate of start.$y − Specifies the y- coordinate of start.$border − Specifies the border color.$color − Specifies the color.Return ValuesIt returns True ... Read More

Draw Filled Polygon Using imagefilledpolygon Function in PHP

Urmila Samariya
Updated on 09-Aug-2021 11:51:48

428 Views

imagefilledpolygon() is an inbuilt PHP function that is used to draw a filled polygon.Syntaxbool imagefilledpolygon($image, $points, $num_points, $color)Parametersimagefilledpolygon() takes four different parameters − $image, $points, $num_points, and $color.$image − Creates a blank image in a given size using the imagecreatetruecolor() function.$points − Holds the sequential vertices of the polygon.$num_points − Contains the total number of vertices in a polygon. The total number of points/vertices must be at least three to create a polygon.$color − Contains the filled color identifier using imagecolorallocate() function.Return ValuesIt returns True on success and False on failure.Example 1OutputExample 2OutputRead More

Draw Partial Arc and Fill it Using imagefilledarc Function in PHP

Urmila Samariya
Updated on 09-Aug-2021 11:46:55

399 Views

imagefilledarc() is an inbuilt function in PHP that is used to draw a partial arc and fill it.Syntaxbool imagefilledarc($image, $cx, $cy, $width, $height, $start, $end, $color, $style)Parametersimagefilledarc() takes nine parameters: $image, $cx, $cy, $width, $height, $start, $end, $color, and $style.$image − It is returned by the image creation function imagecreatetruecolor(). This function is used to create the size of the image.$cx − Sets the x-coordinate of the center.$cy − Sets the y-coordinate of the center.$width − Sets the arc width.$height − Sets the arc height.$start − Start angle in degrees.$end − Arc end angle, in degrees. 00 is located at ... Read More

Draw an Ellipse Using imageellipse Function in PHP

Urmila Samariya
Updated on 09-Aug-2021 11:43:12

774 Views

imageellipse() is an inbuilt function in PHP that is used to draw an ellipse. It returns True on success and False on failure.SyntaxBool imageellipse($image, $cx, $cy, $width, $height, $color)Parametersimageellipse() takes six different paramters: $image, $cx, $cy, $width, $height, $color.$image − Creates the size of the image. It is returned by one of the image creation functions, such as imagecreatetruecolor().$cx − Sets the x-coordinate of the center.$cy − Sets the y-coordinate of the center.$width − Sets the ellipse width.$height − Sets the ellipse height.$color − Sets the color of ellipse. A color identifier created by imagecolorallocate() function.Return ValuesIt returns True on ... Read More

Create New True Color Image in PHP Using imagecreatetruecolor

Urmila Samariya
Updated on 09-Aug-2021 11:39:48

1K+ Views

imagecreatetruecolor( ) is an inbuilt function in PHP that is used to create a new true-color image. It returns a blank image of the given size.Syntaxresource imagecreatetruecolor($width, $height)Parametersimagecreatetruecolor() takes two paramters, $width and $height.$width − The $width parameter is used to set the image width.$height − The $height parameter is used to set the image height.Return Valuesimagecreatetruecolor() returns an image resource identifier on success or it returns false on errors.Example 1OutputExample 2 − Below PHP code will create a new GD image streamOutput

Crop Image to Given Rectangle Using ImageCrop Function in PHP

Urmila Samariya
Updated on 09-Aug-2021 11:08:50

3K+ Views

imagecrop() is an inbuilt function in PHP that is used to crop an image to the given rectangle. It crops the image from the given rectangle area and returns the output image.The given image is not modified.Syntaxresource imagecrop ($image, $rect)Parametersimagecrop() takes two parameters, $image and $rect.$image − It is the parameter returned by the image creation functions, such as imagecreatetruecolor(). It is used to create the size of an image.$rect − The cropping rectangle is an array with keys X, Y, width, and height.Return Valuesimagecrop() returns the cropped image resource on success or it returns false on failure.ExampleOutputInput image before ... Read More

Crop Image Automatically Using imagecropauto Function in PHP

Urmila Samariya
Updated on 09-Aug-2021 10:12:07

1K+ Views

imagecropauto() is an inbuilt function in PHP that is used to crop an image automatically using one of the available modes.Syntaxresource imagecropauto(resource $image, int $mode, float $threshold, int $color)Parametersimagecropauto() takes four different parameters − $image, $mode, $threshold and $color.$image − Specifies the image resource to be cropped.$mode − It is an optional parameter and it is used to specify an integer corresponding to a crop mode, below is the list of crop modes.IMG_CROP_DEFAULT − The IMG_CROP_DEFAULT works just like the IMG_CROP_TRANSPARENT mode.IMG_CROP_TRANSPARENT − This mode is used to crop out a transparent background.IMG_CROP_BLACK − This mode is used to crop ... Read More

Destroy Image in PHP Using imagedestroy Function

Urmila Samariya
Updated on 09-Aug-2021 10:05:23

654 Views

imagedestroy() is an inbuilt PHP function that is used to destroy an image and free any memory associated with the image.Syntaxbool imagedestroy(resource $image)Parametersimagedestroy() takes only one parameter, $image. It holds the name of an image.Return Valuesimagedestroy() returns true on success and failure on false.Example 1 − Destroying an image after loading it.OutputNote − By using imagedestroy() function, we have destroyed the $cropped variable and therefore, it can no longer be accessed.Explanation − In Example1, imagecreatefrompng() loads an image from the local drive folder and crops a part of the image from the given image using imagecropauto() function. After cropping, imagedestroy() ... Read More

Create New Image from WEBP File or URL in PHP

Urmila Samariya
Updated on 09-Aug-2021 10:02:15

2K+ Views

In PHP, imagecreatefromwebp() is an inbuilt PHP function that is used to create a new image from a WEBP file or URL. imagecreatefromwebp() returns an image identifier representing the image obtained from the given filename.imagecreatefromwebp() can be used whenever we want to edit the images after loading them from a WEBP file. Using imagewebp(), an image can be converted into WBMP.Syntaxresource imagecreatefromwebp(string $filename)Parametersimagecreatefromwebp() takes only one parameter, $filename. It holds the name of the image.Return Valuesimagecreatefromwebp() returns an image resource identifier on success, and it gives an error on false.Example 1OutputNote − The above PHP code will load the content ... Read More

Create New Image from WBMP File or URL Using imagecreatefromwbmp in PHP

Urmila Samariya
Updated on 09-Aug-2021 09:58:16

265 Views

In PHP, imagecreatefromwbmp() is an inbuilt function that is used to create a new image from a WBMP file or URL. imagecreatefromwbmp() returns an image identifier representing the image obtained from the given filename. We can use imagecreatefromwbmp() whenever we want to edit the images after loading them from a WBMP file. Using the imagewbmp() function, an image can be converted into WBMP.Syntaxresource imagecreatefromwbmp(string $filename)Parametersimagecreatefromwbmp() takes only one parameter, $filename. It holds the name of the image.Return Valuesimagecreatefromwbmp() returns an image resource identifier on success, and it gives an error on false.Example 1

Advertisements