Skip to content

Instantly share code, notes, and snippets.

@ichimarusakura
Created September 23, 2016 01:45
Show Gist options
  • Select an option

  • Save ichimarusakura/836f262efe701ebcc9d55037204e5cc7 to your computer and use it in GitHub Desktop.

Select an option

Save ichimarusakura/836f262efe701ebcc9d55037204e5cc7 to your computer and use it in GitHub Desktop.
ForDeviceImageConvertor
import io,os,struct,codecs,glob,binascii
from PIL import Image
imgs = glob.iglob('slices//*.*')
for img in imgs:
fo_img = Image.open(img)
filename = os.path.basename(img)
basename, extname = os.path.splitext(filename)
o_path = 'bmp//'
if os.path.isdir(o_path) == False:
os.mkdir(o_path)
temp_img = Image.new('RGB', fo_img.size)
temp_img.paste(fo_img, (0, 0))
print("coverted %s" % basename+extname)
temp_img.save(o_path + basename + '.bmp','bmp',dpi=(72,72))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment