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/77a720e04ff317651b190ebcba119b5a to your computer and use it in GitHub Desktop.

Select an option

Save ichimarusakura/77a720e04ff317651b190ebcba119b5a to your computer and use it in GitHub Desktop.
JacketEditor
import io,os,struct,codecs,glob,binascii
from PIL import Image
imgs = glob.iglob('png\\*.*')
for img in imgs:
fo_img = Image.open(img)
filename = os.path.basename(img)
basename, extname = os.path.splitext(filename)
newb_img = Image.new('RGBA', (320, 320), (255, 255, 255, 0))
news_img = Image.new('RGBA', (160, 160), (255, 255, 255, 0))
o_path = 'jacket\\'
if os.path.isdir(o_path) == False:
os.mkdir(o_path)
if fo_img.size != (320, 320):
rb_img = fo_img.resize((320, 320), Image.LANCZOS)
newb_img.paste(rb_img, (0, 0))
newb_img.save(o_path + 'BNR_BIG_ID' + basename + '.png', 'png')
else:
newb_img.paste(fo_img, (0, 0))
newb_img.save(o_path + 'BNR_BIG_ID' + basename + '.png', 'png')
if fo_img.size != (160, 160):
rb_img = fo_img.resize((160, 160), Image.LANCZOS)
news_img.paste(rb_img, (0, 0))
news_img.save(o_path + 'BNR_ID' + basename + '.png', 'png')
else:
news_img.paste(fo_img, (0, 0))
news_img.save(o_path + 'BNR_ID' + basename + '.png', 'png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment