Beispiel #1
0
        working_dir = '{}/Downloads/renders/{}px'.format(
            homedir, template['name'])
        os.makedirs(working_dir, exist_ok=True)
    except FileExistsError:
        pass

    ad = Offer(drawBot, template, args.spotlight)
    i = 0

    for c in COLORS:
        frame_path = template['name'] + c + '@2x'
        face = faces[randint(0,
                             len(faces) - 1)]  # pick a random portrait to use
        i += 1
        print('Rendering {} of {}'.format(i, len(COLORS)))
        ad.render(frame_path, face, args.copy, args.cta, args.offer)
        fp = "{}/Downloads/renders/{}px/{}-{}.png".format(
            homedir, template['name'], template['name'], 'offer' + c)
        ad.save(fp)
        ad.end()

        # resize the image
        with open(fp, 'r+b') as f:
            with Image.open(f) as img:
                img = Image.open(f)
                img = resizeimage.resize_width(
                    img,
                    int(template['name'].split('_')[0]) * 2)
                img.save(fp + '@2x.png', img.format)
                img = resizeimage.resize_width(
                    img, int(template['name'].split('_')[0]))