PHP头条
热点:

php图像处理常用函数与实例


简单的生成验证码图片代码

<?php教程
header("Content-type: image/jpeg");
// 载入图像
$imagen1 = imagecreatefromjpeg("imagen1.jpg");
$imagen2 = imagecreatefromjpeg("imagen2.jpg");

// 复制图像www.111cn.net
imagecopy($imagen1,$imagen2,0,0,0,0,200,150);

// 输出jpeg图像
imagejpeg($imagen1);

//释放内存
imagedestroy($imagen2);
imagedestroy($imagen1);

?>

获取图片属性代码

<?php
$info = getimagesize("imagen2.jpg");
print_r($info);

?>

生成png图片的php代码

<?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);
 ?>

www.phpzy.comtrue/php/34714.htmlTechArticlephp图像处理常用函数与实例 简单的生成验证码图片代码 ?php教程 header(Content-type: image/jpeg); // 载入图像 $imagen1 = imagecreatefromjpeg(imagen1.jpg); $imagen2 = imagecreatefromjpeg(imagen2.jpg); // 复制图像...

相关文章

    暂无相关文章

PHP之友评论

今天推荐