Simple example of php image processing_PHP tutorial

WBOY
Release: 2016-07-13 10:45:44
Original
721 people have browsed it

imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

According to your php tutorial and gd version whether the function is defined or not. For php 4.0.6 through 4.1.x this function always exists

,
*/
$im=imagecreatetruecolor(100,100); //Create image
$string='n'; //Define character
$white=imagecolorallocate($im,255,255,255); //Define white
$black=imagecolorallocate($im,0,0,0); //Define black
$red=imagecolorallocate($im,255,0,0); //Define red
//Output a black "z" on a white background, which is actually an upside-down n
imagecharup($im,6,20,20,$string,$white);
imagechar($im,2,40,40,"r",$red); //Use red to draw the character
header('content-type: image/png'); //Output header information
imagepng($im); //Output png file
imagedestroy($im); //Destroy the image

//

$img=imagecreatetruecolor(400,400); //Create image
$white=imagecolorallocate($img,255,255,255); //Define white
$black=imagecolorallocate($img,0,0,0); //Define black
imagearc($img,200,200,350,350,0,360,$white); //Draw an elliptical arc
header("content-type: image/png"); //Output header information
imagepng($img); //Output is png image
imagedestroy($img); //Destroy the image

//
$size=300;
$image=imagecreatetruecolor($size,$size);
//Draw a square with a white background and a black border
$back=imagecolorallocate($image,255,255,255);
$border=imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,0,0,$size-1,$size-1,$back);
imagerectangle($image,0,0,$size-1,$size-1,$border);
$yellow_x=100;
$yellow_y=75;
$red_x=120;
$red_y=165;
$blue_x=187;
$blue_y=125;
$radius=150;
//Assign some color with alpha value
$yellow=imagecolorallocatealpha($image,255,255,0,75);
$red=imagecolorallocatealpha($image,255,0,0,75);
$blue=imagecolorallocatealpha($image,0,0,255,75);
//Draw three overlapping circles
imagefilledellips tutorial e($image,$yellow_x,$yellow_y,$radius,$radius,$yellow);
imagefilledellipse($image,$red_x,$red_y,$radius,$radius,$red);
imagefilledellipse($image,$blue_x,$blue_y,$radius,$radius,$blue);
//Output header file header
header('content-type: image/png');
//Final output result
imagepng($image);
imagedestroy($image);

//

$im=imagecreate(100,100);    //Create image
$string='php'; //Define string
$bg=imagecolorallocate($im,255,255,255); //Define white
$black=imagecolorallocate($im,0,0,0); //Define black
//Output the specified character
in the upper left corner imagechar($im,1,0,0,$string,$black);
header('content-type: image/png'); //Output header information
imagepng($im); //Output png file
imagedestroy($im); //Destroy the image

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632992.htmlTechArticleimagecreatetruecolor() returns an image identifier representing a black image of the specified size. Depending on whether the function is defined in your php tutorial and gd version. For php 4.0.6 through 4.1.x this function...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template