Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ##################confik######################
- $myf = "https://i.ibb.co/m8bqPNR/1017509-781581171892976-4155322701169993926-n.png"; //source file
- $tinggi = "40"; //px resize
- $lebar = "40"; //px resize
- $simbol = "@";
- ###############################################
- echo "<body style='background-color:black;'>";
- ##############tuk resaiz pic##################
- function resaiz($file, $w, $h, $crop=FALSE)
- {
- list($width, $height) = getimagesize($file);
- $r = $width / $height;
- if ($crop)
- {
- if($width > $height)
- {
- $width = ceil($width-($width*abs($r-$w/$h)));
- }
- else
- { $height = ceil($height-($height*abs($r-$w/$h)));
- }
- $newwidth = $w; $newheight = $h;
- }
- else
- {
- if ($w/$h > $r)
- {
- $newwidth = $h*$r; $newheight = $h;
- }
- else
- {
- $newheight = $w/$r; $newwidth = $w;
- }
- }
- $src = imagecreatefrompng($file);
- $dst = imagecreatetruecolor($newwidth, $newheight);
- imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
- return $dst;
- }
- ##############################################
- $im = resaiz($myf, $lebar, $tinggi);
- $w = imagesx($im);
- $h = imagesy($im);
- $adj = $lebar-1;
- ##############################################
- for($x = 0; $x < $h; $x++)
- {
- $tz = 0;
- for($y = 0; $y < $w; $y++)
- {
- ##########tuk detect color&ubh to hex#######
- $color = imagecolorat($im, $y, $x);
- $cl = imagecolorsforindex($im, $color);
- $clr = array_values($cl);
- $cls = sprintf("#%02x%02x%02x", $clr[0], $clr[1], $clr[2]);
- $tz = $tz+1;
- echo "<font style='color:".$cls."'>".$simbol."</font>";
- #kalau hujung pic <br#######################
- if($tz > $adj)
- {
- echo "<br />";
- }
- }
- }
- echo "</body>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement