php interesting avatar puzzle_PHP tutorial

WBOY
Release: 2016-07-13 10:19:49
Original
1068 people have browsed it

php interesting avatar puzzle

When I was researching the GD library of PHP, I found a piece of code written by others. I am giving it here in the hope of increasing everyone's enthusiasm for PHP. This code mosaics the character's avatar with code, which looks interesting.


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 = &#39;http://www.bkjia.com/uploads/allimg/140830/0421361239-0.png&#39;;
$text = &#39;I-dont-like-manga-...-Why-do-they-have-such-big-eyes? Strange-...-WHAT-WANT-YOU-DO?&#39;;

Header(&#39;Content-Type: image/png&#39;);
imagepng(pixelfuck($url, $text, 1, 6));
Copy after login

The one below is the original image and the other is the processed image.








www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/871192.htmlTechArticlephp Interesting avatar puzzle When researching the GD library of php, I found a piece of code written by others, which is given here. I hope to increase everyone's enthusiasm for php. This code codes the character avatar...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template