Found 26504 Articles for Server Side Programming

How to get the clipping rectangle using imagegetclip() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 12:23:26

120 Views

imagegetclip() is an inbuilt PHP function that is used to get the clipping rectangle. It is used to retrieve the current clipping rectangle, the area beyond which no pixels will be drawn.Syntaxarray imagegetclip(resource $image)Parametersimagegetclip() takes only one parameter, $image. It holds the image resource returned by one of the image creation functions such as imagecreatetruecolor().Return Typesimagegetclip() returns an indexed array with the coordinates of the clipping rectangle x, y upper left corner, and x, y lower-left corner.Example 1OutputArray (    [0] => 20    [1] => 20    [2] => 90    [3] => 90 )Example 2OutputArray (    [0] => 0    [1] => 0    [2] => 611    [3] => 395 )

How to get the pixel width of a character in the specified font using the imagefontwidth() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 12:20:34

591 Views

imagefontwidth() is an inbuilt function in PHP that is used to get the pixel width of a character in the specified font.Syntaxint imagefontwidth(int $font)Parametersimagefontwidth() takes only one parameter, $font. It holds the font value. The $font values can be 1, 2, 3, 4, and 5 for the built-in fonts or it can be used by using imageloadfont() function for custom fonts.Return Valuesimagefontwidth() returns the pixel width of the font.Example 1 Live DemoOutputFont width: 7Example 2 Live DemoOutputFont width for the font value 1 is 5 Font width for the font value 2 is 6 Font width for the font value 3 is ... Read More

How to get the pixel height of a character in the specified font using the imagefontheight() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 12:17:14

296 Views

imagefontheight() is an inbuilt function in PHP that is used to get the pixel height of a character in the specified font.Syntaxint imagefontheight(int $font)Parametersimagefontheight() takes one parameter, $font. It holds the font value. The $font values can be 1, 2, 3, 4, and 5 for the built-in fonts or it can be used by using imageloadfont() function for custom fonts.Return Valuesimagefontheight() returns the pixel height of the font.Example 1 Live DemoOutputFont height: 13Example 2 Live DemoOutputFont height for the font value 1 is 8 Font height for the font value 2 is 13 Font height for the font value 3 is ... Read More

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

Urmila Samariya
Updated on 09-Aug-2021 12:02:58

914 Views

imagefilter() is an inbuilt function in PHP that is used to apply a given filter to an image.Syntaxbool imagefilter(resource $image, int $filtertype, int $arg1, int $arg2, int $arg3, int $arg4)Parametersimagefilter() takes six different parameters − $image, int $filtertype, int $arg1, int $arg2, int $arg3, int $arg4.$image − It holds the image resource.$filtertype − Specifies the filter to be used which is an integer.Below are the given different image filter constants −IMG_FILTER_NEGATE − Reverses all the colors of an image.IMG_FILTER_GRAYSCALE − Converts the image into the grayscale by changing the red, green, and blue components to their weighted sum.IMG_FILTER_BRIGHTNESS − Changes ... Read More

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

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

381 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

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

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

417 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

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

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

392 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

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

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

766 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

How to create a 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

How to crop an image to the given rectangle using imagecrop() function using 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

Advertisements