Example #1
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/boo/boo.bmp").convert("RGBA")
        # We need a text layer here for the rotation
        canv = ImageDraw.Draw(base)

        text = text.split(", ")

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        first, second = text

        first_font, first_text = auto_text_size(
            first,
            ImageFont.truetype("assets/fonts/sans.ttf"),
            144,
            font_scalar=0.7)
        second_font, second_text = auto_text_size(
            second,
            ImageFont.truetype("assets/fonts/sans.ttf"),
            144,
            font_scalar=0.7)

        canv.text((35, 54), first_text, font=first_font, fill="Black")
        canv.text((267, 57), second_text, font=second_font, fill="Black")
        base = base.convert("RGB")

        b = BytesIO()
        base.save(b, format="jpeg")
        b.seek(0)
        return send_file(b, mimetype="image/jpeg")
Example #2
0
async def boo(request):
    args = await getarg(request)
    base = Image.open("assets/boo/boo.bmp").convert("RGBA")
    canv = ImageDraw.Draw(base)

    text = args[2]

    if len(text) != 2:
        text = ["Separate the items with a", "comma followed by a space"]

    first, second = text

    first_font, first_text = auto_text_size(
        first,
        ImageFont.truetype("assets/fonts/sans.ttf"),
        144,
        font_scalar=0.7)
    second_font, second_text = auto_text_size(
        second,
        ImageFont.truetype("assets/fonts/sans.ttf"),
        144,
        font_scalar=0.7)

    canv.text((35, 54), first_text, font=first_font, fill="Black")
    canv.text((267, 57), second_text, font=second_font, fill="Black")
    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})
Example #3
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(
            self.assets.get('assets/master/master.bmp')).convert('RGBA')
        text = text.split(',')
        if len(text) == 3:
            a, b, c = text
        else:
            a, b, c = ('split by commas', 'for this command',
                       'you need 3 items')
        font, text1 = auto_text_size(
            a,
            self.assets.get_font('assets/fonts/sans.ttf'),
            250,
            font_scalar=0.2)
        font, text2 = auto_text_size(b, font, 250, font_scalar=0.3)
        font, text3 = auto_text_size(c, font, 300, font_scalar=0.2)
        canv = ImageDraw.Draw(base)
        text_layer = Image.new('RGBA', base.size)
        tilted_text = ImageDraw.Draw(text_layer)

        canv.text((148, 151), text1, font=font, fill='White')
        tilted_text.text((350, 330), text2, font=font, fill='White')
        canv.text((457, 513), text3, font=font, fill='White')

        text_layer = text_layer.rotate(8, resample=Image.BICUBIC)

        base.paste(text_layer, (0, 0), text_layer)
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
    def generate(self, avatars, text, usernames):
        base = Image.open(
            'assets/knowyourlocation/knowyourlocation.jpg').convert('RGBA')
        # We need a text layer here for the rotation
        canv = ImageDraw.Draw(base)

        text = text.split(', ')

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        top, bottom = text

        top_font, top_text = auto_text_size(
            top, ImageFont.truetype(font='assets/fonts/sans.ttf'), 630)
        bottom_font, bottom_text = auto_text_size(
            bottom, ImageFont.truetype(font='assets/fonts/sans.ttf'), 539)

        canv.text((64, 131), top_text, font=top_font, fill='Black')
        canv.text((120, 450), bottom_text, font=bottom_font, fill='Black')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Example #5
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/knowyourlocation/knowyourlocation.bmp").convert(
            "RGBA"
        )
        # We need a text layer here for the rotation
        canv = ImageDraw.Draw(base)

        text = text.split(", ")

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        top, bottom = text

        top_font, top_text = auto_text_size(
            top, ImageFont.truetype("assets/fonts/sans.ttf"), 630
        )
        bottom_font, bottom_text = auto_text_size(
            bottom, ImageFont.truetype("assets/fonts/sans.ttf"), 539
        )
        render_text_with_emoji(base, canv, (64, 131), top_text, top_font, "black")
        render_text_with_emoji(
            base, canv, (120, 450), bottom_text, bottom_font, "black"
        )
        base = base.convert("RGB")

        b = BytesIO()
        base.save(b, format="jpeg")
        b.seek(0)
        return send_file(b, mimetype="image/jpeg")
Example #6
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/master/master.bmp").convert("RGBA")
        text = text.split(",")
        if len(text) == 3:
            a, b, c = text
        else:
            a, b, c = ("you need 3 items", "for this command",
                       "split by commas")
        font, text1 = auto_text_size(
            a,
            ImageFont.truetype("assets/fonts/sans.ttf"),
            250,
            font_scalar=0.2)
        font, text2 = auto_text_size(b, font, 250, font_scalar=0.3)
        font, text3 = auto_text_size(c, font, 300, font_scalar=0.2)
        canv = ImageDraw.Draw(base)
        text_layer = Image.new("RGBA", base.size)
        tilted_text = ImageDraw.Draw(text_layer)

        canv.text((457, 513), text1, font=font, fill="White")
        tilted_text.text((350, 330), text2, font=font, fill="White")
        canv.text((148, 151), text3, font=font, fill="White")

        text_layer = text_layer.rotate(8, resample=Image.BICUBIC)

        base.paste(text_layer, (0, 0), text_layer)
        base = base.convert("RGB")

        b = BytesIO()
        base.save(b, format="jpeg")
        b.seek(0)
        return send_file(b, mimetype="image/jpeg")
Example #7
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/balloon/balloon.bmp')).convert('RGBA')
        font = self.assets.get_font('assets/fonts/sans.ttf')
        canv = ImageDraw.Draw(base)

        text = text.split(', ')

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        balloon, label = text

        balloon_text_1_font, balloon_text_1 = auto_text_size(balloon, font, 162)
        balloon_text_2_font, balloon_text_2 = auto_text_size(balloon, font, 170, font_scalar=0.95)
        balloon_text_3_font, balloon_text_3 = auto_text_size(balloon, font, 110, font_scalar=0.8)
        label_font, label_text = auto_text_size(label, font, 125)

        render_text_with_emoji(base, canv, (80, 180), balloon_text_1, font=balloon_text_1_font, fill='Black')
        render_text_with_emoji(base, canv, (50, 530), balloon_text_2, font=balloon_text_2_font, fill='Black')
        render_text_with_emoji(base, canv, (500, 520), balloon_text_3, font=balloon_text_3_font, fill='Black')
        render_text_with_emoji(base, canv, (620, 155), label_text, font=label_font, fill='Black')
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Example #8
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(
            self.assets.get('assets/changemymind/changemymind.bmp')).convert(
                'RGBA')
        # We need a text layer here for the rotation
        text_layer = Image.new('RGBA', base.size)
        font, text = auto_text_size(
            text, self.assets.get_font('assets/fonts/sans.ttf'), 310)
        canv = ImageDraw.Draw(text_layer)

        render_text_with_emoji(text_layer,
                               canv, (290, 300),
                               text,
                               font=font,
                               fill='Black')

        text_layer = text_layer.rotate(23, resample=Image.BICUBIC)

        base.paste(text_layer, (0, 0), text_layer)
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Example #9
0
async def balloon(request):
    args = await getarg(request)
    text = args[2]
    base = Image.open("assets/balloon/balloon.bmp").convert("RGBA")
    font = ImageFont.truetype("assets/fonts/sans.ttf")
    canv = ImageDraw.Draw(base)
    if len(text) != 2:
        text = ["Separate the items with a", "comma followed by a space"]

    balloon, label = text

    balloon_text_1_font, balloon_text_1 = auto_text_size(balloon, font, 162)
    balloon_text_2_font, balloon_text_2 = auto_text_size(balloon,
                                                         font,
                                                         170,
                                                         font_scalar=0.95)
    balloon_text_3_font, balloon_text_3 = auto_text_size(balloon,
                                                         font,
                                                         110,
                                                         font_scalar=0.8)
    label_font, label_text = auto_text_size(label, font, 125)

    render_text_with_emoji(base,
                           canv, (80, 180),
                           balloon_text_1,
                           font=balloon_text_1_font,
                           fill="Black")
    render_text_with_emoji(base,
                           canv, (50, 530),
                           balloon_text_2,
                           font=balloon_text_2_font,
                           fill="Black")
    render_text_with_emoji(base,
                           canv, (500, 520),
                           balloon_text_3,
                           font=balloon_text_3_font,
                           fill="Black")
    render_text_with_emoji(base,
                           canv, (620, 155),
                           label_text,
                           font=label_font,
                           fill="Black")
    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})
Example #10
0
    def generate(self, avatars, text, usernames):
        base = Image.open('assets/balloon/balloon.jpg').convert('RGBA')
        font = ImageFont.truetype(font='assets/fonts/sans.ttf')
        canv = ImageDraw.Draw(base)

        text = text.split(', ')

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        balloon, label = text

        balloon_text_1_font, balloon_text_1 = auto_text_size(
            balloon, font, 162)
        balloon_text_2_font, balloon_text_2 = auto_text_size(balloon,
                                                             font,
                                                             170,
                                                             font_scalar=0.95)
        balloon_text_3_font, balloon_text_3 = auto_text_size(balloon,
                                                             font,
                                                             110,
                                                             font_scalar=0.8)
        label_font, label_text = auto_text_size(label, font, 125)

        canv.text((80, 180),
                  balloon_text_1,
                  font=balloon_text_1_font,
                  fill='Black')
        canv.text((50, 530),
                  balloon_text_2,
                  font=balloon_text_2_font,
                  fill='Black')
        canv.text((500, 520),
                  balloon_text_3,
                  font=balloon_text_3_font,
                  fill='Black')
        canv.text((620, 155), label_text, font=label_font, fill='Black')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Example #11
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/humansgood/humansgood.bmp')).convert('RGBA')
        # We need a text layer here for the rotation
        font, text = auto_text_size(text, self.assets.get_font('assets/fonts/sans.ttf'),
                                    125, font_scalar=0.7)
        canv = ImageDraw.Draw(base)
        render_text_with_emoji(base, canv, (525, 762), text, font, 'black')
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/knowyourlocation/knowyourlocation.bmp')).convert('RGBA')
        # We need a text layer here for the rotation
        canv = ImageDraw.Draw(base)

        text = text.split(', ')

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        top, bottom = text

        top_font, top_text = auto_text_size(top, self.assets.get_font('assets/fonts/sans.ttf'), 630)
        bottom_font, bottom_text = auto_text_size(bottom,
                                                  self.assets.get_font('assets/fonts/sans.ttf'),
                                                  539)
        render_text_with_emoji(base, canv, (64, 131), top_text, top_font, 'black')
        render_text_with_emoji(base, canv, (120, 450), bottom_text, bottom_font, 'black')
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Example #13
0
    def generate(self, avatars, text, usernames):
        base = Image.open('assets/boo/boo.png').convert('RGBA')
        # We need a text layer here for the rotation
        canv = ImageDraw.Draw(base)

        text = text.split(', ')

        if len(text) != 2:
            text = ["Separate the items with a", "comma followed by a space"]

        first, second = text

        first_font, first_text = auto_text_size(first, ImageFont.truetype(font='assets/fonts/sans.ttf'), 144,
                                                font_scalar=0.7)
        second_font, second_text = auto_text_size(second, ImageFont.truetype(font='assets/fonts/sans.ttf'), 144,
                                                  font_scalar=0.7)

        canv.text((35, 54), first_text, font=first_font, fill='Black')
        canv.text((267, 57), second_text, font=second_font, fill='Black')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Example #14
0
async def armor(request):
    base = Image.open("assets/armor/armor.bmp").convert("RGBA")
    args = await getarg(request)
    text = args[2][0]
    font = ImageFont.truetype("assets/fonts/sans.ttf")
    font, text = auto_text_size(text, font, 207, font_scalar=0.8)
    canv = ImageDraw.Draw(base)

    render_text_with_emoji(base,
                           canv, (34, 371),
                           text,
                           font=font,
                           fill="Black")
    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})
Example #15
0
    def generate(self, avatars, text, usernames):
        base = Image.open('assets/armor/armor.png').convert('RGBA')
        # We need a text layer here for the rotation
        font, text = auto_text_size(
            text,
            ImageFont.truetype(font='assets/fonts/sans.ttf'),
            207,
            font_scalar=0.8)
        canv = ImageDraw.Draw(base)

        canv.text((34, 371), text, font=font, fill='Black')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Example #16
0
    def generate(self, avatars, text, usernames):
        base = Image.open('assets/changemymind/changemymind.jpg').convert('RGBA')
        # We need a text layer here for the rotation
        text_layer = Image.new('RGBA', base.size)
        font, text = auto_text_size(text, ImageFont.truetype(font='assets/fonts/sans.ttf'), 310)
        canv = ImageDraw.Draw(text_layer)

        canv.text((290, 300), text, font=font, fill='Black')

        text_layer = text_layer.rotate(23, resample=Image.BICUBIC)

        base.paste(text_layer, (0, 0), text_layer)

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Example #17
0
    def generate(self, avatars, text, usernames):
        base = Image.open('assets/vr/vr.jpg').convert('RGBA')
        # We need a text layer here for the rotation
        font, text = auto_text_size(
            text,
            ImageFont.truetype(font='assets/fonts/sans.ttf'),
            207,
            font_scalar=0.8)
        canv = ImageDraw.Draw(base)
        w, h = canv.textsize(text)
        canv.multiline_text(((170 - w), 485),
                            text,
                            font=font,
                            fill='Black',
                            anchor='center')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Example #18
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/vr/vr.bmp").convert("RGBA")
        # We need a text layer here for the rotation
        font, text = auto_text_size(
            text,
            ImageFont.truetype("assets/fonts/sans.ttf"),
            207,
            font_scalar=0.8)
        canv = ImageDraw.Draw(base)
        w, _ = canv.textsize(text, font)
        render_text_with_emoji(base,
                               canv, (int((170 - (w / 2))), 485),
                               text,
                               font=font,
                               fill="Black")
        base = base.convert("RGB")

        b = BytesIO()
        base.save(b, format="jpeg")
        b.seek(0)
        return send_file(b, mimetype="image/jpeg")
Example #19
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/vr/vr.bmp')).convert('RGBA')
        # We need a text layer here for the rotation
        font, text = auto_text_size(
            text,
            self.assets.get_font('assets/fonts/sans.ttf'),
            207,
            font_scalar=0.8)
        canv = ImageDraw.Draw(base)
        w, _ = canv.textsize(text, font)
        render_text_with_emoji(base,
                               canv, (int((170 - (w / 2))), 485),
                               text,
                               font=font,
                               fill='Black')
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Example #20
0
async def changemymind(request):
    base = Image.open("assets/changemymind/changemymind.bmp").convert("RGBA")
    text_layer = Image.new("RGBA", base.size)
    args = await getarg(request)
    text = args[2][0]
    font, text = auto_text_size(text,
                                ImageFont.truetype("assets/fonts/sans.ttf"),
                                310)
    canv = ImageDraw.Draw(text_layer)

    render_text_with_emoji(text_layer,
                           canv, (290, 300),
                           text,
                           font=font,
                           fill="Black")

    text_layer = text_layer.rotate(23, resample=Image.BICUBIC)

    base.paste(text_layer, (0, 0), text_layer)
    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})