One: PHP Create a new picture step:
1 : Create canvas:
$im =imagecreatetruecolor (300,80)
2: Define color:
$black =imagecolorallocate ($im, 0, 0, 0);
3: Fill Color | text message:
Imagefill ($im, 0, 0, $black);
4: Create Picture:
Imagepng ($im, "./data/01.png")
5: Destroying images:
Imagedestroy ($im);
Simple example:
1 //1: Create a drawing resource (canvas)2 $im=imagecreatetruecolor (300,80);3 4 //2: Create color5 $black=imagecolorallocate ($im, 0, 0, 0);6 7 //3: Fill Color (paint)8Imagefill ($im, 0, 0,$black);9 Ten One //4: Save picture A if(Imagepng ($im, "./data/01.png")){ - Echo"Picture saved successfully"; -}Else{ the EchoFailed; - } - - //5: Destroy canvas, release resources +Imagedestroy ($im);
Two: Introduce a picture as a canvas
$image =imagecreatefromjpeg ("./data/1.jpg");
Follow the same steps
Tip: More picture operations and functions please go to the manual to view GD
Basic steps for PHP drawing GD Library