<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                >[success] # 圖片轉ASCII碼圖 * [案例圖](http://www.degraeve.com/img2txt.php) * [手把手教你圖片轉ASCII碼圖](https://www.cnblogs.com/jelly7723/p/5657891.html) * [圖片轉字符](https://segmentfault.com/a/1190000007692741) ![](https://box.kancloud.cn/b577e6d90fa106b736db964948927712_896x428.png) ![](https://box.kancloud.cn/bd855ff2eadf838f37becc2a62f9d23a_919x525.jpg) ~~~php <?php function tochars($r, $g, $b, $px = 256, $char = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ@$%??__ff--++~~'' ::.. `` ") { if ($px == 0) return ''; $len = mb_strlen($char); //灰度值 $gray = floor(($r + $g + $b) / 3); //將256個像素平均分配給字符 $unit = ceil($px / $len); //獲取當前像素對應的字符 $index = floor($gray / $unit); if ($index >= $len) { $index = $len - 1; } return $char[(int)$index]; } function tosmallim($const = 100, $width, $height, $image) { if ($width > $const) { $times = floor($width / $const); $smwidth = $const; $smheight = floor($height / $times); $im = imagecreatetruecolor($smwidth, $smheight); imagecopyresampled($im, $image, 0, 0, 0, 0, $smwidth, $smheight, $width, $height); return [$im, $smwidth, $smheight]; } return [$image, $width, $height]; } $imname = 'http://images2015.cnblogs.com/blog/763758/201606/763758-20160612082543871-1901077809.png'; //返回一圖像標識符,代表了從給定的文件名取得的圖像 $image = ImageCreateFromPng($imname); //$im = ImageCreateFromJpeg($imname); $size = getimagesize($imname); $width = $size[0]; $height = $size[1]; list($image, $width, $height) = tosmallim(100, $width, $height, $image); $arr = []; for ($i = 0; $i < $height; $i++) { for ($j = 0; $j < $width; $j++) { $rgb = ImageColorat($image, $j, $i); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $arr[] = floor(($r + $g + $b) / 3); } } $num = count(array_unique($arr)); $str = '<span style="font-size: 8pt; letter-spacing: 4px; line-height: 8pt; font-weight: bold;display: block; font-family: monospace; white-space: pre; margin: 1em 0;">'; for ($i = 0; $i < $height; $i++) { for ($j = 0; $j < $width; $j++) { $rgb = ImageColorat($image, $j, $i); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $str .= tochars($r, $g, $b, $num); } $str .= '<br>'; } echo $str . '</span>'; ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看