php 头像拼图,php 有趣的头像拼图
研究php的GD庫的時候,發(fā)現(xiàn)了一段他人寫的代碼,這里給出來希望增加大家對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
for($x=0;$x
imagestring($img,$weight,$x*$size,$y*$size, $chars{@++$p%$cc}, imagecolorat($resource, $x, $y));
return $img;
}
$url = 'http://upload.wikimedia.org/wikipedia/commons/b/be/Manga_Icon.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));
下面一個是原圖像,一個是經(jīng)過處理后的圖像。
總結(jié)
以上是生活随笔為你收集整理的php 头像拼图,php 有趣的头像拼图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php mysql筛选查询,php-Vi
- 下一篇: curl封装php,PHP封装curl的