def process_iphone(self, dim, width, height):
background = Image.new('RGBA', size=(1536, 2726), color=self.bg_color)
# Maybe we should consider a blur background some other time, a plain background will do for now
# scrshot2 = self.screenshot_image.resize((1536, 2726), PIL.Image.ANTIALIAS)
# background = scrshot2.filter(ImageFilter.GaussianBlur(radius=12))
self.set_text(background, self.desc_text, self.desc_font, 'desc')
self.set_text(background, self.title_text, self.title_font, 'title')
# ------------------
iphone_type = ('iphone6plus' if dim > 4 else 'iphone5')
iphone_device = Image.open("%s/devices/%s.png" % (get_script_dir(), iphone_type))
background.paste(iphone_device, (0, 0), iphone_device)
if dim <= 4:
img2 = self.screenshot_image.resize((1135, 1800), PIL.Image.ANTIALIAS)
background.paste(img2, (200, 920))
else:
img2 = self.screenshot_image.resize((1147, 1906), PIL.Image.ANTIALIAS)
background.paste(img2, (190, 820))
if not os.path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)
destination_dir = OUTPUT_DIR + '/%s' % dim
if not os.path.isdir(destination_dir):
os.mkdir(destination_dir)
background = background.resize((width, height), PIL.Image.ANTIALIAS)
valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
file_name = ''.join(c for c in self.title_text if c in valid_chars)
background.convert('RGB').save("%s/%s.jpg" % (destination_dir, file_name))
评论列表
文章目录