💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 图片转字符 ```php //图片转字符 // $lei->color_dodge_blend($im,2,$width,$height); $image_path = "1.jpg"; // $image_path="2.png"; $im = imagecreatefromjpeg($image_path); $imgWidth = imagesx($im); $imgHeight = imagesy($im); for($i=0;$i<$imgHeight;$i++) for($j=0;$j<$imgWidth;$j++) { $rgb = ImageColorAt($im, $j,$i); $r=($rgb>>16); //取得红色分量 $g=($rgb&0x00ff00)>>8; //取得绿色分量 $b=$rgb&0x0000ff; //取得蓝色分量 $t=($r*3+$g*6+$b)/10;//转成灰度 $t=floor($t); if($t<25) //输出ascii { echo "@"; }else if($t<50) { echo "B"; }else if($t<75) { echo "A"; }else if($t<100) { echo "@"; }else if($t<125) { echo "9"; }else if($t<150) { echo "*"; }else if($t<175) { echo "+"; }else if($t<200) { echo ";"; }else if($t<=225) { echo ","; }else{ echo "."; } if($j>$imgWidth-2) //跟着图片换行 echo "\r\n"; } die; ```