img2pix

Gesponsorde koppelingen

PHP script bestanden

  1. img2pix

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
error_reporting(E_ALL);
$cfg = array();
$cfg['img'] = 'img.jpg'; // plaats van de foto
$cfg['perpix_v'] = 1; // per hoeveel pixels kijkt hij (verticaal)
$cfg['perpix_h'] = 1; // per hoeveel pixels kijkt hij (horizontaal)
$cfg['size'] = 5; // Symbool grootte in px
$cfg['symbol'] = 'M'; // Welk symbool gebruikt hij voor een pixel
$cfg['bg'] =  ''; // Achtergrond kleur in hex, FALSE voor geen achtergrond
function getstream($filename){
    if(@imagecreatefromgif($filename)){
        return imagecreatefromgif($filename);    
    }

    elseif(@imagecreatefromjpeg($filename)){
        return imagecreatefromjpeg($filename);    
    }

    elseif(@imagecreatefrompng($filename)){
        return imagecreatefrompng($filename);    
    }

    elseif(@imagecreatefromwbmp($filename)){
        return imagecreatefromwbmp($filename);    
    }
}
function
rgb2hex($r, $g, $b){
   if($r < 0 || $r > 255 || !is_numeric($r)) { $r = 0; }
   if($g < 0 || $g > 255 || !is_numeric($g)) { $g = 0; }
   if($b < 0 || $b > 255 || !is_numeric($b)) { $b = 0; }
   $color = array($r, $g, $b);
   $hexcolor = "#" . sprintf("%02X", $r) . sprintf("%02X", $g) . sprintf("%02X", $b);
   return $hexcolor;
}
  
$stream=getstream($cfg['img']);
?>

<html>
    <head>
        <title>Dotted version of <?=$cfg['img'];?></title>
        <style type="text/css">
        body{
            font-size: <?=$cfg['size'];?>px;
            <?=($cfg['bg'] != FALSE)?'background-color: '.$cfg['bg'].';':'';?>
        }
        </style>
    </head>
<body>
<?php
for($b=0;$b<imagesy($stream)/$cfg['perpix_h'];$b++){
    for($a=0;$a<imagesx($stream)/$cfg['perpix_v'];$a++){
        $rgb=imagecolorat($stream, $a * $cfg['perpix_h'], $b * $cfg['perpix_v']);
        $rgb=array((($rgb >> 16) & 0xFF), (($rgb >> 8) & 0xFF), ($rgb & 0xFF));
        echo '<font color="'.rgb2hex($rgb[0], $rgb[1], $rgb[2]).'">'.$cfg['symbol'].'</font>';
    }

    echo '<br>';
}

?>

</body>
</html>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.