Simple generation of verification code image code
header("Content-type: image/jpeg");
//Load image
$imagen1 = imagecreatefromjpeg("imagen1.jpg");
$imagen2 = imagecreatefromjpeg("imagen2.jpg");// Copy image www.bKjia.c0m
imagecopy($imagen1,$imagen2,0,0,0,0,200,150);// Output jpeg image
imagejpeg($imagen1);//Release memory
imagedestroy($imagen2);
imagedestroy($imagen1);?>
Get image attribute code
$info = getimagesize("imagen2.jpg");
print_r($info);?>
PHP code to generate png images
//PNG format image processing function
function Loadpng ($imgname) {
$im = @ImageCreateFromPNG ($imgname);
If (!$im) { //Failed to load image $im = ImageCreate (400, 30); $bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
ImageString($im, 4, 5, 5, "Error loading: $imgname", $tc);
}
Return $im;
}
$imgPng=Loadpng("./karte.png");
/* Output the image to the browser */
header("Content-type: image/png");
imagePng($imgPng);
?>
http://www.bkjia.com/PHPjc/633050.html