
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2862 of 3368

65 Views
The imagecolorstotal() function gets the count of colors in an image's paletteSyntaximagecolorstotal (img)Parametersimg: Image created with imagecreatetruecolor().ReturnThe imagecolorstotal() function returns the number of colors in an image palette.ExampleThe following is an example Live DemoOutputThe following is the output:Number of Colors = 128

120 Views
The imagecolorset() function sets the color for the specified palette index. Using this create flood-fill-like effects in palleted images.Syntaximagecolorset ( img, index, red, green, blue, alpha )Parametersimg: Image created with imagecreatetruecolor() functionindex: The index in the palette imagered: Value of red componentgreen: Value of green componentblue: Value of blue componentalpha: The transparency if image.ReturnThe imagecolorset() function returns nothing.ExampleThe following is an exampleOutputThe following is the output:

104 Views
The imagecolorsforindex() function gets the colors for an index.Syntaximagecolorsforindex ( img, index )Parametersimg: Creates an image with imagecreatetruecolor()Index: Set the color index.ReturnThe imagecolorsforindex() function returns an associative array with red, green, blue and alpha keys that contain the appropriate values for the specified color index.ExampleThe following is an example Live DemoOutputThe following is the output:array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }

51 Views
The imagecolorresolvealpha() function is used to get the index of the specified color with alpha.Syntaximagecolorresolvealpha (img , red , green , blue , alpha )Parametersimg: Creates an image with imagecreatetruecolor().red: The red componentgreen: The green componentblue: The blue componentalpha: Value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.ReturnThe imagecolorresolvealpha() function returns the color index.ExampleThe following is an example Live DemoOutputThe following is the output:Array ( [0] => 128 [1] => 129 [2] => 130 )

87 Views
The imagecopymergegray() function is used to copy and merge part of an image with gray scale.Syntaximagecopymerge ( dst_img, src_img, dst_x, dst_y, src_x, src_y, src_w, src_h, pct )Parametersdst_im Set destination image link resource.src_im Set source image link resource.dst_xSet x-coordinate of destination point.dst_y Set y-coordinate of destination point.src_x Set x-coordinate of source point.src_y Set y-coordinate of source point.src_w Set source width.src_h Set source height.pct The src_im will be changed to grayscale according to pct where 0 is fully grayscale and 100 is unchanged.ReturnThe imagecopymergegray() function returns the TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example wherein we have set ... Read More

881 Views
The imagecopy() function is used to copy part of an image.Syntaximagecopy( dst_img, src_img, dst_x, dst_y, src_x, src_y, src_w, src_h)Parametersdst_im Set destination image link resource.src_im Set source image link resource.dst_x Set x-coordinate of destination point.dst_y Set y-coordinate of destination point.src_x Set x-coordinate of source point.src_y Set y-coordinate of source point.src_w Set source width.src_h Set source height.ReturnThe imagecopy() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example wherein part of an image is copied:OutputThe following is the output:Read More

791 Views
The imagecopymerge() function copy and merge part of an image.Syntaximagecopymerge ( dst_img, src_img, dst_x, dst_y, src_x, src_y, src_w, src_h, pct )Parametersdst_im Set destination image link resource.src_im Set source image link resource.dst_x Set x-coordinate of destination point.dst_y Set y-coordinate of destination point.src_x Set x-coordinate of source point.src_y Set y-coordinate of source point.src_w Set source width.src_h Set source height.pct The two images will be merged according to pct which can range from 0 to 100.ReturnThe imagecopymerge() function returns the TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output displaying the merge of two images:ExampleLet us see ... Read More

53 Views
The imagecharup() function is used to draw a character vertically.Syntaximagecharup( img, font, x, y, c, color )Parametersimg: Create an image with imagecreatetruecolor()font: Sets the font size. It can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encodingx: x-coordinatey: y-coordinatec: character to be drawncolor: color identifierReturnThe imagecharup() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example:OutputThe following is the output that draws character E with different dimensions:

145 Views
The imagechar() function draws a character horizontally.Syntaxbool imagechar( img, font, x, y, ch, color )Parametersimg: Creating an image with imagecreatetruecolor().font: Set font sizex: x-coordinatey: y-coordinatec: The character to draw.color: A color identifier created with imagecolorallocate().ReturnThe imagechar() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example wherein we are drawing a character with different coordinates and height/ width as shown in the above example:OutputThe following is the output:

357 Views
The imagearc() function is used to draw an arc.Syntaximagearc( $img, $cx, $cy, $width, $height, $start, $end, $color )Parameters$img: Creates an image with imagecreatetruecolor().$cx: x-coordinate of the center.$cy: y-coordinate of the center.$width: The width of arc.$height: The height of arc.$start: The arc start angle, in degrees.$end: The arc end angle in degrees.$color: It sets the color of image.ReturnThe imagearc() function returns the TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example wherein we have different coordinates and angle for arc:OutputThe following is the output:Read More