Skip to content

Instantly share code, notes, and snippets.

@ichimarusakura
Last active May 12, 2020 08:14
Show Gist options
  • Select an option

  • Save ichimarusakura/80ed419095e0713da242b69cd775d1b9 to your computer and use it in GitHub Desktop.

Select an option

Save ichimarusakura/80ed419095e0713da242b69cd775d1b9 to your computer and use it in GitHub Desktop.
IDXCreator
from PIL import Image,ImageDraw,ImageFont
fo = open('name.txt','r')
for names in fo:
uc = []
ab = []
#color font
color = '#000000'
color1 = '#000000'
font = 'dfgothw5.ttc'
#name size
nms = 22
snm = 12
#artist size
ars = 15
id, name, artist = names.split('\n')[0].split(',')
for char in name:
if char >= '\u3000' and char <= '\u9fff':
uc.append(char)
if char >= '\u0020' and char <= '\u007e':
ab.append(char)
img0 = Image.new('RGBA', (324, 40), (255, 255, 255, 0))
img1 = Image.new('RGBA',((len(uc)*22+len(ab)*11)+2, 24),(255, 255, 255, 0))
img2 = Image.new('RGBA', (324, 16), (255, 255, 255, 0))
img3 = Image.new("RGBA", (160, 24), (255, 255, 255, 0))
img32= Image.new('RGBA',((len(uc)*12+len(ab)*6)+2, 24),(255, 255, 255, 0))
fnt1 = ImageFont.truetype(font, nms)
fnt2 = ImageFont.truetype(font, ars)
fnt3 = ImageFont.truetype(font, snm)
drw1 = ImageDraw.Draw(img1)
drw2 = ImageDraw.Draw(img2)
drw3 = ImageDraw.Draw(img32)
drw1.text((1, 1), name, font = fnt1, fill = color)
drw1.text((1, 1), name, font = fnt1, fill = color)
drw2.text((1, 0), artist, font = fnt2, fill = color)
drw2.text((1, 0), artist, font = fnt2, fill = color)
drw3.text((0, 0), name, font = fnt3, fill = color1)
drw3.text((0, 0), name, font = fnt3, fill = color1)
if img1.size[0] > 324 :
imgr = img1.resize((324, 24),Image.LANCZOS)
img0.paste(imgr,(0, 0))
img0.paste(img2, (0, 24))
img0.save('IDX_ID'+id+'.png','png')
else:
img0.paste(img1,(0, 0))
img0.paste(img2,(0, 24))
img0.save('IDX_ID'+id + '.png', 'png')
if img32.size[0] > 140 :
imgs = img32.resize((140, 24),Image.LANCZOS)
img3.paste(imgs,(19, 5))
img3.save('IDX_MINI_ID'+id+'.png','png')
else:
img3.paste(img32, (19, 5))
img3.save('IDX_MINI_ID'+id+'.png','png')
from PIL import Image,ImageDraw,ImageFont
#NameCreator For Plus v1.0; Power by Python 3.5 Pillow 3.3.0
fo = open('name.txt','r')
for names in fo:
uc = []
ab = []
#color font
color = '#000000'
color1 = '#000000'
font = 'DF-HeiSeiGothic-W7.ttc'
#name size
nms = 25
#artist size
ars = 14
id, name, artist = names.split('\n')[0].split(',')
for char in name:
if char >= '\u3000' and char <= '\u9fff':
uc.append(char)
if char >= '\u0020' and char <= '\u007e':
ab.append(char)
img0 = Image.new('RGBA', (340,64), (255, 255, 255, 0))
img1 = Image.new('RGBA',((len(uc)*25+len(ab)*14)+2, 26),(255, 255, 255, 0))
img2 = Image.new('RGBA', (340, 16), (255, 255, 255, 0))
fnt1 = ImageFont.truetype(font, nms)
fnt2 = ImageFont.truetype(font, ars)
drw1 = ImageDraw.Draw(img1)
drw2 = ImageDraw.Draw(img2)
drw1.text((0, 0), name, font = fnt1, fill = color)
drw2.text((0, 0), artist, font = fnt2, fill = color)
drw2.text((0, 0), artist, font = fnt2, fill = color)
if img1.size[0] > 340 :
imgr = img1.resize((340, 26),Image.LANCZOS)
img0.paste(imgr,(4, 11))
img0.paste(img2, (4, 39))
img0.save('name_b'+id+'.png','png')
#img0.show()
else:
img0.paste(img1,(4, 11))
img0.paste(img2,(4, 39))
img0.save('name_b'+id + '.png', 'png')
#img0.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment