日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

8.PHP图像处理

發(fā)布時間:2025/6/17 php 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 8.PHP图像处理 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

PHP圖像處理

GD2


Jpgraph


創(chuàng)建一個畫布:

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


創(chuàng)建一個柱形圖

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


總結(jié)

以上是生活随笔為你收集整理的8.PHP图像处理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。