Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

How to apply a filter to an image using imagefilter() function in PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 1K+ Views

The imagefilter() function is a built-in PHP function that applies various visual effects and filters to images. It's commonly used for image processing tasks like adjusting brightness, applying blur effects, or converting images to grayscale. Syntax bool imagefilter(resource $image, int $filtertype, int $arg1, int $arg2, int $arg3, int $arg4) Parameters imagefilter() accepts the following parameters − $image − The image resource to apply the filter to. $filtertype − The filter constant that specifies which filter to apply. $arg1, $arg2, $arg3, $arg4 − Optional arguments that depend on the filter type. ...

Read More

Flood fill to specific color in PHP using imagefilltoborder() (GD) function.

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 486 Views

The imagefilltoborder() function is a PHP GD library function that performs flood fill with a specific color, filling a region until it reaches a defined border color. The fill starts from a specified point (x, y) and spreads until it encounters the border color. Syntax bool imagefilltoborder(resource $image, int $x, int $y, int $border, int $color) Parameters The imagefilltoborder() function accepts five parameters ? $image − The image resource created by image creation functions $x − X-coordinate of the starting point for the fill $y ...

Read More

How to draw a filled polygon using an imagefilledpolygon() function in PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 528 Views

The imagefilledpolygon() function is a built-in PHP function used to draw a filled polygon on an image. This function requires the GD extension to be enabled and creates solid-filled geometric shapes with multiple vertices. Syntax bool imagefilledpolygon($image, $points, $num_points, $color) Parameters The imagefilledpolygon() function takes four parameters − $image − An image resource created using imagecreatetruecolor() or similar functions. $points − An array containing the sequential x, y coordinates of polygon vertices in pairs. $num_points − The total number of vertices in the polygon. Must be at least 3 to form a ...

Read More

How to draw a partial arc and fill it using imagefilledarc() function in PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 501 Views

The imagefilledarc() function is a built-in PHP function used to draw and fill a partial arc. This function requires the GD extension and is commonly used for creating pie charts, progress indicators, and other graphical elements. Note: To use imagefilledarc(), you need the GD extension enabled in PHP. Install it using: sudo apt-get install php-gd on Ubuntu/Debian or enable it in php.ini on Windows. Syntax bool imagefilledarc($image, $cx, $cy, $width, $height, $start, $end, $color, $style) Parameters The imagefilledarc() function takes nine parameters − $image − Image resource created by ...

Read More

How to draw an ellipse using imageellipse() function in PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 934 Views

The imageellipse() function is an inbuilt PHP function used to draw an ellipse on an image resource. It returns True on success and False on failure. Syntax bool imageellipse($image, $cx, $cy, $width, $height, $color) Parameters The imageellipse() function takes six parameters − $image − An image resource created by functions like imagecreatetruecolor(). $cx − The x-coordinate of the ellipse center. $cy − The y-coordinate of the ellipse center. $width − The width of the ellipse. $height − The height of the ellipse. $color − The color identifier created by imagecolorallocate() function. ...

Read More

How to create a new true-color image in PHP using imagecreatetruecolor()?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 1K+ Views

The imagecreatetruecolor() function is an inbuilt function in PHP that creates a new true-color image resource. It returns a blank image canvas of the specified dimensions that can be used for drawing operations. Syntax resource imagecreatetruecolor($width, $height) Parameters The imagecreatetruecolor() function takes two parameters: $width − The width of the image in pixels. $height − The height of the image in pixels. Return Value Returns an image resource identifier on success, or FALSE on errors. Example 1 − Creating a Polygon Image This example creates a true-color ...

Read More

How to crop an image to the given rectangle using imagecrop() function using PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 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. Syntax resource imagecrop ($image, $rect) Parameters imagecrop() 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. ...

Read More

How to crop an image automatically using imagecropauto() function in PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 1K+ Views

The imagecropauto() function is an inbuilt PHP function that automatically crops an image using one of the available modes to remove unwanted borders or backgrounds. Note: This function requires the GD extension. Install it using: sudo apt-get install php-gd (Linux) or enable it in php.ini (Windows/XAMPP). Syntax resource imagecropauto(resource $image, int $mode, float $threshold, int $color) Parameters imagecropauto() accepts four parameters − $image, $mode, $threshold, and $color. $image − The image resource to be cropped. $mode − Optional. Specifies the crop mode: IMG_CROP_DEFAULT − Works like IMG_CROP_TRANSPARENT mode. ...

Read More

How to destroy an image in PHP using imagedestroy() function?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 793 Views

The imagedestroy() function is an inbuilt PHP function used to destroy an image resource and free any memory associated with it. This function is essential for preventing memory leaks when working with image processing in PHP. Syntax bool imagedestroy(resource $image) Parameters $image − An image resource created by one of the image creation functions like imagecreatetruecolor() or imagecreatefrompng(). Return Value Returns true on success or false on failure. Example 1 − Creating and Destroying a Simple Image Here's a basic example of creating an image and then destroying it ? ...

Read More

How to create a new image from a JPEG file using the imagecreatefromjpeg() function in PHP?

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 3K+ Views

The imagecreatefromjpeg() function is an inbuilt PHP function that creates a new image resource from a JPEG file. It returns an image identifier representing the image obtained from the given filename. Syntax resource imagecreatefromjpeg(string $filename) Parameters $filename − The name or path to the JPEG image file to be loaded. Return Value Returns an image resource identifier on success, or false on failure. Note: This function requires the GD extension to be enabled in PHP. Example 1 − Basic Image Loading and Display The following example shows ...

Read More
Showing 22171–22180 of 61,298 articles
Advertisements