Home >Backend Development >PHP Tutorial >PHP image processing common functions and examples_PHP tutorial

PHP image processing common functions and examples_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:45:12879browse

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

truehttp: //www.bkjia.com/PHPjc/633050.htmlTechArticleSimple generation of verification code image code?php tutorial header(Content-type: image/jpeg); // Load Input image $imagen1 = imagecreatefromjpeg(imagen1.jpg); $imagen2 = imagecreatefromjpeg(imagen...
Statement:
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