程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php 有趣的頭像拼圖

php 有趣的頭像拼圖

編輯:關於PHP編程

php 有趣的頭像拼圖


研究php的GD庫的時候,發現了一段他人寫的代碼,這裡給出來希望增加大家對php的熱情。這段代碼對人物頭像進行了代碼的馬賽克,看起來很有趣。


function pixelfuck($url, $chars='ewk34543§G§$§$Tg34g4g', $shrpns=1, $size=4,$weight=2)
{
    list($w, $h, $type) = getimagesize($url);
    $resource = imagecreatefromstring(file_get_contents($url));
    $img = imagecreatetruecolor($w*$size,$h*$size);

    $cc = strlen($chars);
    for($y=0;$y <$h;$y+=$shrpns) 
        for($x=0;$x <$w;$x+=$shrpns)
            imagestring($img,$weight,$x*$size,$y*$size, $chars{@++$p%$cc}, imagecolorat($resource, $x, $y));
    return $img;
}

$url = 'https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011710210121.png';
$text = 'I-dont-like-manga-...-Why-do-they-have-such-big-eyes? Strange-...-WHAT-WANT-YOU-DO?';

Header('Content-Type: image/png');
imagepng(pixelfuck($url, $text, 1, 6));

下面一個是原圖像,一個是經過處理後的圖像。



\

\


\\



  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved