PHP图像处理

GD2

Jpgraph

创建一个画布:

<?php
    header('content-type:image/gif');
    //echo "你好";
    $im = imagecreate(200,60);
    $white = imagecolorallocate($im ,225 ,66 ,159);
    imagegif($im);
?>

显示一张图片

<?php
        function LoadPNG($imgname)
        {
            /* Attempt to open */
            $im = @imagecreatefromjpeg($imgname);
            /* See if it failed */
            if(!$im){
                echo "aaa";
                /* Create a blank image */
                $im  = imagecreatetruecolor(150,40);
                $bgc = imagecolorallocate($im, 255, 255, 255);
                $tc  = imagecolorallocate($im, 0, 0, 0);
                imagefilledrectangle($im, 0, 0, 150, 40, $bgc);
                /* Output an error message */
                imagestring($im, 1, 5, 5, 'bb ' . $imgname, $tc);
            }
            return $im;
        }

        header('Content-Type: image/jpeg');
        $img = LoadPNG('p.jpg');
        imagepng($img);
        imagedestroy($img);
?>

随机生成验证码:

<?php
    session_start();
    header('Content-Type: image/png');
    $image_width = 70;
    $image_height = 18;
    srand(microtime()*100000);
    $new_number = '';
    for($i = 0 ;$i < 4 ;$i ++){
        $new_number.=dechex(rand(0 ,15));
    }
    $_SESSION['check_checks'] = $new_number;
    $num_image = imagecreate($image_width ,$image_height);
    imagecolorallocate($num_image ,255 ,255 ,255);
    for($i = 0 ;$i < strlen($_SESSION['check_checks']) ;$i ++){
        $font = mt_rand(3 ,5);
        $x = mt_rand(1 ,8) + $image_width * $i / 4;
        $y = mt_rand(1 ,$image_height / 4);
        $color = imagecolorallocate($num_image ,mt_rand(0,100) ,mt_rand(0 ,150) ,mt_rand(0 ,200));
        imagestring($num_image ,$font ,$x ,$y,$_SESSION['check_checks'][$i] ,$color);
    }
    imagepng($num_image);
    imagedestroy($num_image);
?>

创建一个柱形图

<?php
    include ("src/jpgraph.php");
    include ("src/jpgraph_bar.php");
    $datay = array(160 ,180 ,203 ,289 ,405 ,488 ,489 ,408 ,299 ,166 ,187 ,205);
    $graph = new Graph(600 ,300 ,"auto");
    $graph -> SetScale("textlin");
    $graph -> yaxis -> scale -> SetGrace(20);
    $graph -> SetShadow();
    $graph -> img -> SetMargin(40 ,30 ,30 ,40);
    $bplot = new BarPlot($datay);
    $bplot -> SetFillColor('orange');
    $bplot -> value -> Show();
    $bplot -> value -> SetFormat('%d');
    $graph -> Add($bplot);
    $graph -> SetMarginColor("lightblue");
    $graph -> title -> Set("tit");
    $a = array(1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12);
    $graph -> xaxis -> SetTickLabels($a);
    $graph -> title -> SetFont(FF_SIMSUN);
    $graph -> xaxis -> SetFont(FF_SIMSUN);
    $graph -> Stroke();
?>

绘制折线图

<?php
    include ("src/jpgraph.php");
    include ("src/jpgraph_line.php");
    $datay = array(160 ,180 ,203 ,289 ,405 ,488 ,489 ,408 ,299 ,166 ,187 ,500);
    $graph = new Graph(600 ,300 ,"auto");
    $graph -> img -> SetMargin(50 ,40 ,30 ,40);
    $graph -> img -> SetAntiAliasing();
    $graph -> SetScale("textlin");
    $graph -> SetShadow();
    $graph -> title -> Set("tit");
    $graph -> title -> SetFont(FF_SIMSUN ,FS_BOLD);
    $graph -> SetMarginColor("lightblue");
    $graph -> yaxis ->title -> SetFont(FF_SIMSUN);
    $graph -> xaxis -> SetPos("min");
    $graph -> yaxis -> HideZeroLabel();
    $graph -> ygrid -> SetFill(true ,'#EFEFEF@0.5' ,'#BBCCFF@0.5');

    $a = array(1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12);
    $graph -> xaxis -> SetTickLabels($a);
    $graph -> xaxis -> SetFont(FF_SIMSUN);
    $graph -> yscale -> SetGrace(20);

    $p1 = new LinePlot($datay);
    $p1 -> mark -> SetType(MARK_FILLEDCIRCLE);
    $p1  -> mark ->SetFillColor('red');
    $p1 -> mark ->SetWidth(4);
    $p1 -> SetColor('blue');
    $p1 -> SetCenter();
    $graph -> Add($p1);
    $graph -> Stroke();
?>

3D饼状图

<?php
    include ("src/jpgraph.php");
    include ("src/jpgraph_pie.php");
    include ("src/jpgraph_pie3d.php");

    $data = array(160 ,180 ,203 ,289 ,405 ,500 );
    $graph = new PieGraph(540 ,260 ,"auto");
    $graph -> SetShadow();

    $graph -> title -> Set("tit");
    $graph -> title -> SetFont(FF_SIMSUN ,FS_BOLD);
    $graph -> legend -> SetFont(FF_SIMSUN ,FS_NORMAL);

    $p1 = new PiePlot3D($data);
    $p1 -> SetLegends(array('11','22','33','44','55','66'));

    $targ = array("pie3d_csimex1.php?v=1","pie3d_csimex1.php?v=2","pie3d_csimex1.php?v=3","pie3d_csimex1.php?v=4","pie3d_csimex1.php?v=5","pie3d_csimex1.php?v=6");
    $alts = array("val=%d" ,"val=%d" ,"val=%d" ,"val=%d" ,"val=%d" ,"val=%d");
    $p1 -> SetCSIMTargets($targ ,$alts);
    $p1 -> SetCenter(0.4 ,0.5);
    $graph -> Add($p1);
    $graph -> StrokeCSIM();
?>

8.PHP图像处理的更多相关文章

  1. Atitit 图像处理和计算机视觉的分类 三部分 图像处理 图像分析 计算机视觉

    Atitit 图像处理和计算机视觉的分类 三部分 图像处理 图像分析 计算机视觉 1.1. 按照当前流行的分类方法,可以分为以下三部分:三部分 图像处理 图像分析 计算机视觉1 1.2. 图像处理需要 ...

  2. Atitit 图像处理的摩西五经attilax总结

    Atitit 图像处理的摩西五经attilax总结 1. 数字图像处理(第三版)1 2. 图像处理基础(第2版)(世界著名计算机教材精选)1 3. 计算机视觉特征提取与图像处理(第三版)2 4. Op ...

  3. Atitit 图像处理的心得与疑惑 attilax总结

    Atitit 图像处理的心得与疑惑 attilax总结 1.1. 使用类库好不好??还是自己实现算法1 1.2. 但是,如果遇到类库体积太大,后者没有合适的算法,那就只能自己开发算法了1 1.3. 如 ...

  4. Atitit 图像处理 调用opencv 通过java  api   attilax总结

    Atitit 图像处理 调用opencv 通过java  api   attilax总结 1.1. Opencv java api的支持 opencv2.4.2 就有了对java api的支持1 1. ...

  5. Atitit MATLAB 图像处理 经典书籍attilax总结

    Atitit MATLAB 图像处理 经典书籍attilax总结 1.1. MATLAB数字图像处理1 1.2. <MATLAB实用教程(第二版)>((美)穆尔 著)[简介_书评_在线阅读 ...

  6. Atitit 图像处理类库大总结attilax qc20

    Atitit 图像处理类库大总结attilax qc20 1.1. 选择与组合不同的图像处理类库1 1.2. Halcon 貌似商业工具,功能强大.1 1.3. Openvc  Openvc功能也是比 ...

  7. Atitit MATLAB 图像处理attilax总结

    Atitit MATLAB 图像处理attilax总结 1.1. 下载 Matlab7.0官方下载_Matlab2012 v7.0 官方简体中文版-办公软件-系统大全.html1 1.2. Matla ...

  8. 使用MATLAB对图像处理的几种方法(下)

     试验报告 一.试验原理: 图像点处理是图像处理系列的基础,主要用于让我们熟悉Matlab图像处理的编程环境.灰度线性变换和灰度拉伸是对像素灰度值的变换操作,直方图是对像素灰度值的统计,直方图均衡是对 ...

  9. 使用MATLAB对图像处理的几种方法(上)

    实验一图像的滤波处理 一.实验目的 使用MATLAB处理图像,掌握均值滤波器和加权均值滤波器的使用,对比两种滤波器对图像处理结果及系统自带函数和自定义函数性能的比较,体会不同大小的掩模对图像细节的影响 ...

  10. 图像处理中任意核卷积(matlab中conv2函数)的快速实现。

    卷积其实是图像处理中最基本的操作,我们常见的一些算法比如:均值模糊.高斯模糊.锐化.Sobel.拉普拉斯.prewitt边缘检测等等一些和领域相关的算法,都可以通过卷积算法实现.只不过由于这些算法的卷 ...

随机推荐

  1. ThinkAdmin v6 未授权列目录/任意文件读取复现

    大佬的审计文章:https://github.com/zoujingli/ThinkAdmin/issues/244 任意文件读取 POC curl http://127.0.0.1/admin.ht ...

  2. ijkplayer接入使用

    1.ijkplayer简介 ijkplayer是一个基于FFmpeg的轻量级Android/iOS视频播放器.FFmpeg的是全球领先的多媒体框架,能够解码,编码, 转码,复用,解复用,流,过滤器和播 ...

  3. MySQL深入研究--学习总结(4)

    前言 接上文,继续学习后续章节.细心的同学已经发现,我整理的并不一定是作者讲的内容,更多是结合自己的理解,加以阐述,所以建议结合原文一起理解. 第13章<为什么表数据删除一般,表文件大小不变?& ...

  4. Nodejs学习笔记(2) 阻塞/非阻塞实例 与 Nodejs事件

    1. Node.js异步编程的特点 2. 阻塞与非阻塞的实例 2.1 阻塞代码实例 2.2 非阻塞代码实例 3. Node.js的事件驱动 4. 事件循环实例 1. Node.js异步编程的特点 参考 ...

  5. [源码分析] 消息队列 Kombu 之 Hub

    [源码分析] 消息队列 Kombu 之 Hub 0x00 摘要 本系列我们介绍消息队列 Kombu.Kombu 的定位是一个兼容 AMQP 协议的消息队列抽象.通过本文,大家可以了解 Kombu 中的 ...

  6. Hznu_0j 1557

    题目链接:http://acm.hznu.edu.cn/OJ/problem.php?id=1557 题解:将两个数组分别升序和降序排序后,累加差的绝对值. Ac代码: #include<std ...

  7. io流(io流的引入与文件字节流)

    io流的引入与文件字节流 io流:就是一根吸管,插入后,可以操作目标文件 io流的分类: 按方向:输入,输出 按大小:字节,字符 按处理方式: 处理流:"管套着管" --- 流结合 ...

  8. 谷歌SRE运维模式解读

    谷歌SRE运维模式解读 前面我和你分享了一些关于运维组织架构和协作模式转型的内容,为了便于我们更加全面地了解先进的运维模式,今天我们再来谈一下谷歌的SRE(Site Reliability Engin ...

  9. QT实现OPC_UA客户端程序以及与OPC_UA服务器通信

    1.OPC_UA服务器准备工作 1.关于OPC_UA服务器的搭建可以参考前面一篇文章:https://blog.csdn.net/xipengbozai/article/details/1150809 ...

  10. [递推] A. 【例题1】错排问题

    A. [例题1]错排问题 题目描述 求多少个 n n n个数的排列 A A A ,满足对于任意的 i ( 1 ≤ i ≤ n ) i(1 ≤ i ≤ n) i(1≤i≤n) 使 A i ≠ i Ai ...