imagecolorallocate Function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:21:19

611 Views

The imagecolorallocate() function allocates a color for an image.Syntaxint imagecolorallocate ( $img, $red, $green, $blue )Parametersimg: Image resource created with imagecreatetruecolor().red: Red color componentgreen: Green color componentblue: Blue color componentReturnThe imagecolorallocate() function returns a color in RGB format.ExampleThe following is an example:OutputThe following is the output:

imagecolorexact Function in PHP

Arjun Thakur
Updated on 31-Dec-2019 07:20:41

99 Views

The imagecolorexact() function gets the index of the specified color.Syntaximagecolorexact ( $img, $red, $green, $blue )Parametersimg: Image resource created with imagecreatetruecolor().red: Red color componentgreen: Green color componentblue: Blue color componentReturnThe imagecolorexact() function returns the index of the specified color in the palette, or -1 if the color does not exist.ExampleThe following is an example: Live DemoOutputThe following is the output:Array ( [0] => 1989170 [1] => 5273700 [2] => 1658930 )

ImageColorClosestHWB Function in PHP

George John
Updated on 31-Dec-2019 07:20:04

73 Views

The imagecolorclosesthwb() function gets the index of the color which has the hue, white and blacknessSyntaximagecolorclosesthwb ( $img, $red, $green, $blue )Parametersimg: Create image with imagecreatetruecolor()red: Red color componentgreen: Green color componentblue: Blue color componentReturnThe imagecolorclosesthwb() function returns an integer with the index of the color which has the hue, white and blackness nearest the given color.ExampleThe following is an example: Live DemoOutputThe following is the output:HWB = 87

Combine Strings from Many Rows in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:19:50

365 Views

For this, you can use GROUP_CONCAT(). Use SUM() to add the User Id. Let us first create a table −mysql> create table DemoTable1960    (    StudentId int,    StudentName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1960 values(100, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1960 values(101, 'Bob'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1960 values(102, 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1960 values(103, 'Mike'); Query OK, 1 row affected (0.00 sec)Display ... Read More

imagecolorclosestalpha Function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:19:16

90 Views

The imagecolorclosestalpha() function gets the index of closet color with alpha value.Syntaximagecolorclosestalpha ( img, red, green, blue, alpha )Parametersimg: Image resource created with imagecreatetruecolor().red: Red color componentgreen: Green color componentblue: Blue color componentalpha: The transparency of image, with 0 indicating completely opaque, whereas 127 indicating completely transparent.ReturnThe imagecolorclosestalpha() function returns the index of the closest color in the palette.ExampleThe following is an example: Live Demo

ImageFlip Function in PHP

George John
Updated on 31-Dec-2019 07:18:28

328 Views

The imageflip() function is used to flip an image using given mode.Syntaxbool imageflip(img, mode )Parametersimg: An image resource created using imagecreatetruecolor()mode: The flip mode. Here are the possible values:IMG_FLIP_HORIZONTAL – Flips the image horizontally.IMG_FLIP_VERTICAL – Flips the image vertically.IMG_FLIP_BOTH – Flips the image both horizontally and vertically.ReturnThe imageflip() function returns TRUE on success or FALSE on failure.ExampleThe following is an example that flips an image horizontally:OutputThe following is the output:

Create Dynamic Table Name from Current Year in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:18:24

1K+ Views

To create a table name like year (2019), use PREPARE statement. Let us first create a table −mysql> create table DemoTable1959    (    UserName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1959 values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1959 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1959 values('Bob'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1959;This will produce the following output −+----------+ | UserName ... Read More

imagepolygon Function in PHP

Arjun Thakur
Updated on 31-Dec-2019 07:17:56

399 Views

The imagepolygon() function is used to draw a polygon.Syntaxbool imagepolygon( $img, $points, $num_points, $color)Parameters$img: Create a blank image with imagecreatetruecolor() function.$points: An array with vertices of polygon.$num_points: Total number of vertices in a polygon.$color: A color identifier created with imagecolorallocate() function.ReturnThe imagepolygon() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:

jQuery Delay with Examples

AmitDiwan
Updated on 31-Dec-2019 07:17:29

461 Views

The delay() method in jQuery is used to set a delay to delay the execution of the next item in the queue.SyntaxThe syntax is as follows −$(selector).delay(speed, queue)Above, the parameter speed is the speed of delay, whereas the queue is the name of the queue.Let us now see an example to implement the jQuery delay() method −Example Live Demo    $(document).ready(function(){       $("button").click(function(){          $(".demo1").delay("slow").fadeIn();          $(".demo2").delay(500).fadeIn();       });    }); .demo1 {    margin:20px;    width:300px;    height:100px;    display:none;    background-color:red; } .demo2 { ... Read More

Display Auto Increment User ID Sequence Number to Begin from 001 in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:14:27

755 Views

For this, use ZEROFILL and alter the table to begin from the same sequence −alter table yourTableName    change yourColumnName yourColumnName int(3) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY;To understand the above syntax, let us first create a table −mysql> create table DemoTable1958    (    UserId int,    UserName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Here is the query to alter generated sequence number to begin from 001:mysql> alter table DemoTable1958    change UserId UserId int(3) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY; Query OK, 0 rows affected (0.00 sec) Records: 0  Duplicates: 0  Warnings: 0Let ... Read More

Advertisements