字符画吧 关注:1,173贴子:5,612
  • 3回复贴,共1

找到一个工具,可以用字符画出一些好看的东西

只看楼主收藏回复



1楼2021-04-16 17:21回复
    啥软件分享下撒


    IP属地:河北2楼2021-07-31 02:49
    回复

      我这里有更好的,可以手动调清晰度。像这个就很清晰。
      程序是Python程序,代码如下:
      from PIL import Image
      from pygame import *
      from tkinter.filedialog import *
      #char_set = '''$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. '''
      char_set = """▓躝韊矚飅矙蠨雦蠾鑘轥轥驑钄钃隬韈驌騙顨闘飀靂赙駰駎韂騲顤飕騻畹階隞M骫駘禧蜈鎡飔%蛲靔頄搿N蛏焖楂聍柘柩矧宕長怩闫釸饨袷叩佚5忌迲玄C彐引无Y仔玎氿q爿川必不/众玍门}刁王寸疒江兰立y亡广ど辷人ベ廴ソと乛ン辶∵︷゛﹨灬﹣丶﹒ """
      char_two=["M","%","N","5","C","Y","q","/","}","y"," "]
      imgfile=askopenfilename()
      try:
      xx=int(input("最大长:"))
      yy=int(input("最大宽:"))
      except:
      xx=0
      yy=0
      im = Image.open(imgfile).convert("RGBA")
      x,y = im.size # 宽高像素
      img2 = Image.new('RGB', size=(x, y), color=(255, 255, 255))
      img2.paste(im, (0, 0), mask=im)
      im=img2
      #im = Image.frombuffer('RGB', (x, y),image.tostring(image.load(imgfile),"RGB"),"raw", "RGB", 0, 1)
      if y>=x:
      if round(xx / x * y ) <= yy:
      sizeb = (xx, round(xx / x * y ))
      else:
      sizeb = (round(47 / y * x), yy)
      else:
      if round(yy / y * x)<=xx:
      sizeb = (round(yy/y * x), yy)
      else:
      sizeb = (xx, round(xx/ x * y))
      if xx==0 and yy==0:
      sizeb=(x,y)
      im = im.resize(sizeb, Image.ANTIALIAS)
      im = im.convert('L')
      im.save('t.jpeg')
      text = ''
      for i in range(im.height):
      for j in range(im.width):
      gray = im.getpixel((j, i))
      gray = round(gray/255*114
      text += char_set[gray]
      if char_set[gray] in char_two:
      text += char_set[gray]
      text += '\n'
      print(text)
      with open('pic.txt', 'w',encoding="utf-8")as f:
      f.write(text)
      text2=text.split("\n")
      print(text2)
      xxx,yyy=sizeb
      init()
      font1=font.SysFont("simsun", 14)
      aaaa = display.set_mode((xxx*14,yyy*14))
      aaaa.fill("white")
      numm=0
      while True:
      try:
      text3=text2[numm]
      except:
      break
      font.init()
      text = font1.render(text3, True, "black")
      textRect = text.get_rect()
      textRect.center = (xxx * 7, 7+numm*14)
      aaaa.blit(text, textRect)
      numm+=1
      display.flip()
      image.save(aaaa, "1.png")
      quit()


      IP属地:江苏3楼2022-08-17 10:16
      收起回复