Advertisement
tobitaz

pictofont.php

Jun 9th, 2021
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2.  
  3. ##################confik######################
  4. $myf = "https://i.ibb.co/m8bqPNR/1017509-781581171892976-4155322701169993926-n.png"; //source file
  5. $tinggi = "40"; //px resize
  6. $lebar = "40"; //px resize
  7. $simbol = "@";
  8. ###############################################
  9. echo "<body style='background-color:black;'>";
  10. ##############tuk resaiz pic##################
  11. function resaiz($file, $w, $h, $crop=FALSE)
  12. {
  13. list($width, $height) = getimagesize($file);
  14. $r = $width / $height;
  15. if ($crop)
  16. {
  17.  if($width > $height)
  18.  {
  19.   $width = ceil($width-($width*abs($r-$w/$h)));
  20.   }
  21.   else
  22.  { $height = ceil($height-($height*abs($r-$w/$h)));
  23.   }
  24.   $newwidth = $w; $newheight = $h;
  25.   }
  26.   else
  27.   {
  28.    if ($w/$h > $r)
  29.    {
  30.     $newwidth = $h*$r; $newheight = $h;
  31.     }
  32.     else
  33.     {
  34.     $newheight = $w/$r; $newwidth = $w;
  35.     }
  36.      }
  37.      $src = imagecreatefrompng($file);
  38.      $dst = imagecreatetruecolor($newwidth, $newheight);
  39.       imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  40.        return $dst;
  41.         }
  42. ##############################################
  43. $im = resaiz($myf, $lebar, $tinggi);
  44. $w = imagesx($im);
  45. $h = imagesy($im);
  46. $adj = $lebar-1;
  47. ##############################################
  48. for($x = 0; $x < $h; $x++)
  49.  {
  50.  $tz = 0;
  51.  for($y = 0; $y < $w; $y++)
  52.  {
  53. ##########tuk detect color&ubh to hex#######
  54. $color = imagecolorat($im, $y, $x);
  55. $cl = imagecolorsforindex($im, $color);
  56. $clr = array_values($cl);
  57. $cls = sprintf("#%02x%02x%02x", $clr[0], $clr[1], $clr[2]);
  58. $tz = $tz+1;
  59. echo "<font style='color:".$cls."'>".$simbol."</font>";
  60.  
  61. #kalau hujung pic <br#######################
  62. if($tz > $adj)
  63. {
  64. echo "<br />";
  65. }
  66. }
  67. }
  68.  
  69. echo "</body>";
  70.  
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement