Found 1046 Articles for PHP

How to rotate an image with a given angle using imagerotate() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 13:02:24

834 Views

imagerotate() is an inbuilt function in PHP that is used to rotate an image with a given angle in degrees.Syntaxresource imagerotate($image, $angle, $bgd_color, $ignore_transparent = 0)Parametersimagerotate() accepts four parameters, $image, $angle, $bgd_color, and $ignore_transparent.$image − The $image parameter returned by the imagecreatetruecolor() function. It is used to create the size of an image.$angle − The $angle parameter is used to hold the different rotation angles in degrees. It is used to rotate an image in the anticlockwise direction.$bgd_color − Holds the background color of the uncovered zone after the rotation.$ignore_transparent − The $ignore_transparent parameter is used to set and if ... Read More

How to get or set the resolution of an image using imageresolution() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 12:54:22

945 Views

imageresoulution() is an inbuilt function in PHP that is used to get or set the resolution of an image in dots per inch. If no optional parameters are given, then the current resolution is returned as an indexed array. If one of the optional parameters is given, then it will set both the width and height to that parameter.The resolution is only used as meta information when the images are read from and written to formats supporting this kind of information (currently PNG and JPEG). It does not affect any drawing operations. The 96 DPI (dots per inch) is the ... Read More

How to copy the palette from one image to another using imagepalettecopy() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 12:50:53

80 Views

imagepalettecopy() is an inbuilt PHP function that is used to copy the palette from one image to another. This function copies the palette from the source image to the destination image.Syntaxvoid imagepalettecopy(resource $destination, resource $source)Parametersimagepalettecopy() accepts two parameters − $source and $destination.$destination − Specifies the destination image resource.$source − Specifies the source image resource.Return Valuesimagepalettecopy() retuns no values.Example 1OutputExample 2 Live DemoOutputColors in image 1 are 1 Colors in image 2 are 1

How to draw an open polygon using the imageopenpolygon() function n PHP?

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

319 Views

imageopenpolygon() is an inbuilt function in PHP that is used to draw an open polygon on a given image.Syntaxbool imageopenpolygon(resource $image, array $points, int $num_points, int $color)Parametersimageopenpolygon() takes four different parameters: $image, $points, $num_points and$color. $image − Specifies the image resource to work on.$image − Specifies the image resource to work on.$points − Specifies the points of the polygon.$num_points − Specifies the number of points. The total number of (vertices) points must be at least three.$color − This parameter specifies the color of the polygon.Return Valuesimageopenpolygon() returns True on success and False on failure.Example 1OutputExample 2OutputRead More

How to draw a line using imageline() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 12:38:35

2K+ Views

imageline() is an inbuilt function in PHP that is used to draw a line between two given points.Syntaxbool imageline(resource $image, int $x1, int $y1, int $x2, int $y2, int $color)Parametersimageline() takes six different parameters: $image, $x1, $y1, $x2, $y2 and $color.$image − Specifies the image resource to work on.$x1 − Specifies the starting x-coordinate.$y1 − Specifies the starting y-coordinate.$x2 − Specifies the ending x-coordinate.$y2 − Specifies the ending y-coordinate.$color − Specifies the line color and a color identifier created using imagecolorallocate() function.Return Valuesimageline() returns True on success or False on failure.Example 1 − Add a line to an imageOutputExample 2OutputRead More

How to set the alpha blending flag to use layering effects using imaglayereffect() function in PHP?

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

88 Views

imagelayereffect() is an inbuilt function in PHP that is used to set the alpha blending flag to use layering effects. It returns True on success or False on failure.Syntaxbool imagelayereffect($image, $effect)Parametersimagelayereffect() takes two different parameters: $image and $effect.$image − This parameter is returned by the image creation function imagecreatetruecolor(). It is used to create the size of an image.$effect − This parameter is used to set the value of blending flag, using different effect constants, which are given below −IMG_EFFECT_REPLACE − It is used to set the pixel replacement. It is more similar to passing true to imagealphablending() function.IMG_EFFETC_ALPHABLEND − ... Read More

How to ensure an image is a truecolor image using the imageistruecolor() function in PHP?

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

154 Views

imageistruecolor() is an inbuilt function in PHP that is used to check if a given image is a true-color image or not. In a true-color image, each pixel is specified by the RGB (Red, Green, and Blue) color values.Syntaxbool imageistruecolor(resource $image)Parametersimageistruecolor() takes a single parameter, $image. It holds the image.Return Valuesimageistruecolor() returns True if the given image is true-color or else, it returns False if the image is not a true-color image.Example 1Output// Input RGB image// Resultant OutputThe given input image is true-color.Example 2Output// An input gray color image.// OutputThe given input image is not a true-color image.Read More

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

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

68 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

483 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

224 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

Advertisements