简单的生成验证码图片代码
获取图片属性代码
php
$info = getimagesize("imagen2.jpg");
print_r($info);?>
生成png图片的php代码
//PNG格式图像处理函数
function Loadpng ($imgname) {
$im = @ImageCreateFromPNG ($imgname);
if (!$im) { //载入图像失败
$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");
/* 输出图像到浏览器 */
header("Content-type: image/png");
imagePng($imgPng);
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号