Exemplo n.º 1
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open('assets/confusedcat/confusedcat.bmp')
        font = ImageFont.truetype('assets/fonts/medium.woff', size=36)
        canv = ImageDraw.Draw(base)
        try:
            ladies, cat = text.replace(' ,', ',', 1).split(',', 1)
        except ValueError:
            ladies = 'Dank Memer'
            cat = 'People who forget to split text with a comma'
        ladies = wrap(font, ladies, 510)
        cat = wrap(font, cat, 510)
        render_text_with_emoji(base,
                               canv, (5, 5),
                               ladies[:100],
                               font=font,
                               fill='Black')
        render_text_with_emoji(base,
                               canv, (516, 5),
                               cat[:100],
                               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')
Exemplo n.º 2
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/surprised/surprised.bmp").convert("RGBA")
        font = ImageFont.truetype("assets/fonts/robotoregular.ttf", size=36)
        try:
            text1, text2 = text.replace(", ", ",").split(",")
        except ValueError:
            (
                text1,
                text2,
            ) = "tries to use surprised without splitting by comma,the command breaks".split(
                ",")
        text1 = wrap(font, "me: " + text1, 650)
        text2 = wrap(font, "also me: " + text2, 650)
        canv = ImageDraw.Draw(base)
        render_text_with_emoji(base,
                               canv, (20, 20),
                               text1,
                               font=font,
                               fill="White")
        render_text_with_emoji(base,
                               canv, (20, 140),
                               text2,
                               font=font,
                               fill="White")
        base = base.convert("RGB")

        b = BytesIO()
        base.save(b, format="jpeg")
        b.seek(0)
        return send_file(b, mimetype="image/jpeg")
Exemplo n.º 3
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/cheating/cheating.bmp'))
        font = self.assets.get_font('assets/fonts/medium.woff', size=26)
        canv = ImageDraw.Draw(base)
        try:
            me, classmate = text.replace(' ,', ',', 1).split(',', 1)
        except ValueError:
            me = 'aight thx'
            classmate = 'yo dude, you need to split the text with a comma'
        me = wrap(font, me, 150)
        classmate = wrap(font, classmate, 150)
        render_text_with_emoji(base,
                               canv, (15, 300),
                               me[:50],
                               font=font,
                               fill='White')
        render_text_with_emoji(base,
                               canv, (155, 200),
                               classmate[:50],
                               font=font,
                               fill='White')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 4
0
    def generate(self, avatars, text, usernames, kwargs):
        avatar = http.get_image(avatars[0]).resize((52, 52)).convert('RGBA')
        name = usernames[0]
        base = Image.open(self.assets.get('assets/youtube/youtube.bmp')).convert('RGBA')
        font = self.assets.get_font('assets/fonts/robotomedium.ttf', size=17, )
        font2 = self.assets.get_font('assets/fonts/robotoregular.ttf', size=17, )
        font3 = self.assets.get_font('assets/fonts/robotoregular.ttf', size=19, )

        bigsize = (avatar.size[0] * 3, avatar.size[1] * 3)
        mask = Image.new('L', bigsize, 0)
        draw = ImageDraw.Draw(mask)
        draw.ellipse((0, 0) + bigsize, fill=255)
        mask = mask.resize(avatar.size, Image.ANTIALIAS)
        avatar.putalpha(mask)

        base.paste(avatar, (17, 33), avatar)
        canv = ImageDraw.Draw(base)
        op = wrap(font, name, 1150)
        size = canv.textsize(name, font=font)
        comment = wrap(font3, text, 550)
        num = randint(1, 59)
        plural = '' if num == 1 else 's'
        time = f'{num} minute{plural} ago'
        canv.text((92, 34), op, font=font, fill='Black')
        canv.text((100 + size[0], 34), time, font=font2, fill='Grey')
        canv.text((92, 59), comment, font=font3, fill='Black')
        base = base.convert('RGBA')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Exemplo n.º 5
0
async def cheating(request):
    base = Image.open("assets/cheating/cheating.bmp")
    font = ImageFont.truetype("assets/fonts/medium.woff", size=26)
    text = request.headers.get("text")
    canv = ImageDraw.Draw(base)
    try:
        me, classmate = text.replace(" ,", ",", 1).split(",", 1)
    except ValueError:
        me = "aight thx"
        classmate = "yo dude, you need to split the text with a comma"
    me = wrap(font, me, 150)
    classmate = wrap(font, classmate, 150)
    render_text_with_emoji(base,
                           canv, (15, 300),
                           me[:50],
                           font=font,
                           fill="White")
    render_text_with_emoji(base,
                           canv, (155, 200),
                           classmate[:50],
                           font=font,
                           fill="White")

    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})
Exemplo n.º 6
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/sneakyfox/sneakyfox.bmp'))
        font = self.assets.get_font('assets/fonts/arimobold.ttf', size=36)
        canv = ImageDraw.Draw(base)
        try:
            fox, otherthing = text.replace(' ,', ',', 1).split(',', 1)
        except ValueError:
            fox = 'Text that is not split with a comma'
            otherthing = 'the bot'
        fox = wrap(font, fox, 500)
        otherthing = wrap(font, otherthing, 450)
        render_text_with_emoji(base,
                               canv, (50, 385),
                               fox[:180],
                               font=font,
                               fill='Black')
        render_text_with_emoji(base,
                               canv, (670, 150),
                               otherthing[:180],
                               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')
Exemplo n.º 7
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(
            self.assets.get('assets/surprised/surprised.bmp')).convert('RGBA')
        font = self.assets.get_font('assets/fonts/robotoregular.ttf', size=36)
        try:
            text1, text2 = text.replace(', ', ',').split(',')
        except ValueError:
            text1, text2 = 'tries to use surprised without splitting by comma,the command breaks'.split(
                ',')
        text1 = wrap(font, 'me: ' + text1, 650)
        text2 = wrap(font, 'also me: ' + text2, 650)
        canv = ImageDraw.Draw(base)
        render_text_with_emoji(base,
                               canv, (20, 20),
                               text1,
                               font=font,
                               fill='White')
        render_text_with_emoji(base,
                               canv, (20, 140),
                               text2,
                               font=font,
                               fill='White')
        base = base.convert('RGB')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 8
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/violentsparks/violentsparks.bmp")
        font = ImageFont.truetype("assets/fonts/medium.woff", size=36)
        canv = ImageDraw.Draw(base)
        try:
            me, sparks = text.replace(" ,", ",", 1).split(",", 1)
        except ValueError:
            sparks = "me"
            me = "Dank Memer being mad that I forgot to split my text with a comma"
        me = wrap(font, me, 550)
        sparks = wrap(font, sparks, 200)
        render_text_with_emoji(base,
                               canv, (15, 5),
                               me,
                               font=font,
                               fill="White")
        render_text_with_emoji(base,
                               canv, (350, 430),
                               sparks,
                               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")
Exemplo n.º 9
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open('assets/doglemon/doglemon.bmp')
        font = ImageFont.truetype('assets/fonts/medium.woff', size=30)
        canv = ImageDraw.Draw(base)
        try:
            lemon, dog = text.replace(' ,', ',', 1).split(',', 1)
        except ValueError:
            lemon = 'Text that is not seperated by comma'
            dog = 'Dank Memer'
        lemon = wrap(font, lemon, 450)
        dog = wrap(font, dog, 450)
        render_text_with_emoji(base,
                               canv, (850, 100),
                               lemon[:180],
                               font=font,
                               fill='Black')
        render_text_with_emoji(base,
                               canv, (500, 100),
                               dog[:200],
                               font=font,
                               fill='White')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 10
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open("assets/obama/obama.jpg")
        font = ImageFont.truetype("assets/fonts/arimobold.ttf", size=36)
        canv = ImageDraw.Draw(base)

        avatar = (http.get_image(avatars[0]).resize(
            (200, 200), Image.LANCZOS).convert("RGBA"))

        w, _ = canv.textsize(wrap(font, usernames[0], 400), font)

        base.paste(avatar, (120, 73), avatar)
        base.paste(avatar, (365, 0), avatar)

        render_text_with_emoji(
            base,
            canv,
            (int(210 - (w / 2)), 400),
            wrap(font, usernames[0], 400),
            font,
            "white",
        )
        render_text_with_emoji(
            base,
            canv,
            (int(470 - (w / 2)), 300),
            wrap(font, usernames[0], 400),
            font,
            "white",
        )

        base = base.convert("RGB")
        b = BytesIO()
        base.save(b, format="jpeg")
        b.seek(0)
        return send_file(b, mimetype="image/jpeg")
Exemplo n.º 11
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/byemom/mom.bmp'))
        avatar = http.get_image(avatars[0]).convert('RGBA').resize(
            (70, 70), resample=Image.BICUBIC)
        avatar2 = avatar.copy().resize((125, 125), resample=Image.BICUBIC)
        text_layer = Image.new('RGBA', (350, 25))
        bye_layer = Image.new('RGBA', (180, 51), (255, 255, 255))
        font = self.assets.get_font('assets/fonts/arial.ttf', size=20)
        bye_font = self.assets.get_font('assets/fonts/arimobold.ttf', size=14)
        canv = ImageDraw.Draw(text_layer)
        bye = ImageDraw.Draw(bye_layer)
        username = usernames[0] or 'Tommy'
        msg = 'Alright {} im leaving the house to run some errands'.format(
            username)

        text = wrap(font, text, 500)
        msg = wrap(font, msg, 200)

        canv.text((0, 0), text, font=font, fill='Black')
        bye.text((0, 0), msg, font=bye_font, fill=(42, 40, 165))
        text_layer = text_layer.rotate(24.75,
                                       resample=Image.BICUBIC,
                                       expand=True)

        base.paste(text_layer, (350, 443), text_layer)
        base.paste(bye_layer, (150, 7))
        base.paste(avatar, (530, 15), avatar)
        base.paste(avatar2, (70, 340), avatar2)
        base = base.convert('RGBA')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Exemplo n.º 12
0
    def generate(self, avatars, text, usernames, kwargs):
        text = text.replace(', ', ',').split(',')
        if len(text) != 2:
            text = ['SPLIT BY', 'COMMA']
        base = Image.open(self.assets.get('assets/sword/sword.bmp'))
        font = self.assets.get_font('assets/fonts/verdana.ttf', size=48)
        temp = Image.new('RGBA', (1200, 800), color=(0, 0, 0, 0))

        sword = wrap(font, text[0], 3000)
        food = wrap(font, text[1], 300)
        canv = ImageDraw.Draw(base)
        temp_draw = ImageDraw.Draw(temp)
        temp_draw.text((0, 0), sword, font=font, fill='White')
        temp = temp.rotate(-25, expand=1)
        canv.text((330, 330), usernames[0], font=font, fill='White')

        base.paste(temp, (-30, 605), temp)

        size = canv.textsize(food, font=font)

        new_width = (base.width - size[0]) / 2

        canv.text((new_width - 20, 830), food, 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')
Exemplo n.º 13
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(
            self.assets.get('assets/violentsparks/violentsparks.bmp'))
        font = self.assets.get_font('assets/fonts/medium.woff', size=36)
        canv = ImageDraw.Draw(base)
        try:
            me, sparks = text.replace(' ,', ',', 1).split(',', 1)
        except ValueError:
            sparks = 'me'
            me = 'Dank Memer being mad that I forgot to split my text with a comma'
        me = wrap(font, me, 550)
        sparks = wrap(font, sparks, 400)
        render_text_with_emoji(base,
                               canv, (15, 5),
                               me,
                               font=font,
                               fill='White')
        render_text_with_emoji(base,
                               canv, (15, 567),
                               sparks,
                               font=font,
                               fill='White')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 14
0
async def confusedcat(request):
    base = Image.open("assets/confusedcat/confusedcat.bmp")
    font = ImageFont.truetype("assets/fonts/medium.woff", size=36)
    text = request.headers.get("text")
    canv = ImageDraw.Draw(base)
    try:
        ladies, cat = text.replace(" ,", ",", 1).split(",", 1)
    except ValueError:
        ladies = "Dank Memer"
        cat = "People who forget to split text with a comma"
    ladies = wrap(font, ladies, 510)
    cat = wrap(font, cat, 510)
    render_text_with_emoji(base,
                           canv, (5, 5),
                           ladies[:100],
                           font=font,
                           fill="Black")
    render_text_with_emoji(base,
                           canv, (516, 5),
                           cat[:100],
                           font=font,
                           fill="Black")

    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})
Exemplo n.º 15
0
    async def generate(self, request, avatars, text, usernames):
        base = Image.open('assets/byemom/mom.png')
        avatar = await make_avatar(
            Image.open(await http.get_image(request, avatars[0])).convert('RGBA').resize((250, 250), resample=Image.BICUBIC))
        avatar2 = avatar.copy().resize((125, 125), resample=Image.ANTIALIAS)
        avatar = avatar.resize((70, 70), Image.ANTIALIAS).rotate(-27, resample=Image.BICUBIC, expand=True)
        text_layer = Image.new('RGBA', (350, 25))
        bye_layer = Image.new('RGBA', (180, 51), (255, 255, 255))
        font = ImageFont.truetype(font='assets/fonts/arial.ttf', size=20)
        bye_font = ImageFont.truetype(font='assets/fonts/arimobold.ttf', size=14)
        canv = ImageDraw.Draw(text_layer)
        bye = ImageDraw.Draw(bye_layer)
        username = usernames[0] or 'tommy'
        msg = 'Alright {} I\'m leaving the house to run some errands'.format(username)

        text = wrap(font, text, 500)
        msg = wrap(font, msg, 200)

        canv.text((0, 0), text, font=font, fill='Black')
        bye.text((0, 0), msg, font=bye_font, fill=(42, 40, 165))
        text_layer = text_layer.rotate(24.75, resample=Image.BICUBIC, expand=True)

        base.paste(text_layer, (350, 443), text_layer)
        base.paste(bye_layer, (150, 7))
        base.paste(avatar, (513, 2), avatar)
        base.paste(avatar2, (70, 340), avatar2)

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(body=b, content_type='image/png')
Exemplo n.º 16
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/tweet/trump.bmp'))
        avatar = http.get_image(avatars[0]).resize((98, 98)).convert('RGBA')
        font = self.assets.get_font(
            'assets/fonts/segoeuireg.ttf',
            size=50,
        )
        font2 = self.assets.get_font('assets/fonts/robotomedium.ttf', size=40)
        font3 = self.assets.get_font('assets/fonts/robotoregular.ttf', size=29)
        font4 = self.assets.get_font('assets/fonts/robotoregular.ttf', size=35)

        circle = Image.new('L', (20, 20), 0)
        draw = ImageDraw.Draw(circle)
        draw.ellipse((0, 0, 20, 20), fill=255)
        alpha = Image.new('L', avatar.size, 255)
        w, h = avatar.size
        alpha.paste(circle.crop((0, 0, 10, 10)), (0, 0))
        alpha.paste(circle.crop((0, 10, 10, 10 * 2)), (0, h - 10))
        alpha.paste(circle.crop((10, 0, 10 * 2, 10)), (w - 10, 0))
        alpha.paste(circle.crop((10, 10, 10 * 2, 10 * 2)), (w - 10, h - 10))
        avatar.putalpha(alpha)

        base.paste(avatar, (42, 38), avatar)
        canv = ImageDraw.Draw(base)
        text2 = wrap(font2, usernames[0], 1150)
        tag_raw = usernames[1] if len(usernames) == 2 else usernames[0]
        text3 = wrap(font3, f'@{tag_raw}', 1150)

        time = datetime.now().strftime('%-I:%M %p - %d %b %Y')
        retweets = "{:,}".format(randint(0, 99999))
        likes = "{:,}".format(randint(0, 99999))
        text4 = wrap(font3, time, 1150)
        text5 = wrap(font4, retweets, 1150)
        text6 = wrap(font4, likes, 1150)
        total_size = (45, 160)
        for i in text.split(' '):
            i += ' '
            if i.startswith(('@', '#')):
                if total_size[0] > 1000:
                    total_size = (45, total_size[1] + 65)
                canv.text(total_size, i, font=font, fill='#1b95e0')
                y = canv.textsize(i, font=font)
                total_size = (total_size[0] + y[0], total_size[1])
            else:
                if total_size[0] > 1000:
                    total_size = (45, total_size[1] + 65)
                canv.text(total_size, i, font=font, fill='Black')
                y = canv.textsize(i, font=font)
                total_size = (total_size[0] + y[0], total_size[1])
        canv.text((160, 45), text2, font=font2, fill='Black')
        canv.text((160, 95), text3, font=font3, fill='Grey')
        canv.text((40, 570), text4, font=font3, fill='Grey')
        canv.text((40, 486), text5, font=font4, fill='#2C5F63')
        canv.text((205, 486), text6, font=font4, fill='#2C5F63')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Exemplo n.º 17
0
    async def srp(self, ctx):
        """ Displays your Spotify rich presence as an image. """
        if not ctx.author.activity or not isinstance(ctx.author.activity, discord.Spotify):
            return await ctx.send('You need to be listening to Spotify to use this.')

        rp = ctx.author.activity

        spotify_bytes = BytesIO(await requests.get('http://logos-download.com/wp-content/uploads/2016/08/Spotify_logo_black.png'))
        cover_bytes = BytesIO(await requests.get(rp.album_cover_url))

        spotify = Image.open(spotify_bytes).resize((100, 30), resample=Image.LANCZOS).convert('RGBA')
        cover = Image.open(cover_bytes).resize((190, 190), resample=Image.LANCZOS).convert('RGBA')

        dom_col = self.get_dominant(cover)
        should_invert = ((dom_col[0] * 0.299) + (dom_col[1] * 0.587) + (dom_col[2] * 0.114)) <= 64
        text_col = (255, 255, 255) if should_invert else (0, 0, 0)

        if should_invert:
            spotify = self.invert(spotify)

        font = ImageFont.truetype('assets/generators/srp/circular-black.ttf', 23)
        artist_font = font.font_variant(size=18)

        base = Image.new('RGBA', (500, 200), rp.colour.to_rgb())
        overlay = Image.new('RGBA', (490, 190), dom_col)

        #avg = int((dom_col[0] + dom_col[1] + dom_col[2]) / 3)
        #gradient = Image.new('L', (255, 1), color=avg)
        #alpha = 0
        #for x in range(255):
        #    gradient.putpixel((x, 0), alpha)
        #    alpha = min(255, alpha + 7)
        #gradient = gradient.resize(cover.size)
        #cover.putalpha(gradient)

        base.paste(overlay, (5, 5), overlay)
        base.paste(spotify, (10, 10), spotify)
        base.paste(cover, (305, 5), cover)

        title = textutils.wrap(font, rp.title, 290)
        artist = textutils.wrap(artist_font, ', '.join(rp.artists), 290)

        title_height = sum(map(lambda line: font.getsize(line)[1], title.split('\n')))
        a_offset = 55 + title_height

        canv = ImageDraw.Draw(base)
        canv.text((10, 45), title, font=font, fill=text_col)
        canv.text((10, a_offset), artist, font=artist_font, fill=text_col)

        b = BytesIO()
        base.save(b, 'png')
        b.seek(0)

        await ctx.send(content=f'**<https://open.spotify.com/track/{rp.track_id}>**',
                       file=discord.File(b, 'spotify.png'))
Exemplo n.º 18
0
    def generate(self, avatars, text, usernames, kwargs):
        avatar = http.get_image(avatars[0]).resize((52, 52)).convert("RGBA")
        name = usernames[0]
        base = Image.open("assets/youtube/youtube.bmp").convert("RGBA")
        font = ImageFont.truetype(
            "assets/fonts/robotomedium.ttf",
            size=17,
        )
        font2 = ImageFont.truetype(
            "assets/fonts/robotoregular.ttf",
            size=17,
        )
        font3 = ImageFont.truetype(
            "assets/fonts/robotoregular.ttf",
            size=19,
        )

        bigsize = (avatar.size[0] * 3, avatar.size[1] * 3)
        mask = Image.new("L", bigsize, 0)
        draw = ImageDraw.Draw(mask)
        draw.ellipse((0, 0) + bigsize, fill=255)
        mask = mask.resize(avatar.size, Image.ANTIALIAS)
        avatar.putalpha(mask)

        base.paste(avatar, (17, 33), avatar)
        canv = ImageDraw.Draw(base)
        op = wrap(font, name, 1150)
        size = canv.textsize(name, font=font)
        comment = wrap(font3, text, 550)
        num = randint(1, 59)
        plural = "" if num == 1 else "s"
        time = f"{num} minute{plural} ago"
        render_text_with_emoji(base,
                               canv, (92, 34),
                               op,
                               font=font,
                               fill="Black")
        render_text_with_emoji(base,
                               canv, (100 + size[0], 34),
                               time,
                               font=font2,
                               fill="Grey")
        render_text_with_emoji(base,
                               canv, (92, 59),
                               comment,
                               font=font3,
                               fill="Black")
        base = base.convert("RGBA")

        b = BytesIO()
        base.save(b, format="png")
        b.seek(0)
        return send_file(b, mimetype="image/png")
Exemplo n.º 19
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/doglemon/doglemon.bmp'))
        font = self.assets.get_font('assets/fonts/medium.woff', size=30)
        canv = ImageDraw.Draw(base)
        lemon, dog = text.replace(' ,', ',', 1).split(',', 1)
        lemon = wrap(font, lemon, 500)
        dog = wrap(font, dog, 450)
        render_text_with_emoji(base, canv, (750, 150), lemon[:180], font=font, fill='Black')
        render_text_with_emoji(base, canv, (33, 5), dog[:200], font=font, fill='White')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 20
0
    def generate(self, avatars, text, usernames, kwargs):
        text = text.replace(', ', ',').split(',')
        if len(text) != 2:
            text = ['Dank Memer', 'People who do not split with a comma']
        base = Image.open(self.assets.get('assets/lick/lick.jpg'))
        font = self.assets.get_font('assets/fonts/verdana.ttf', size=24)
        canv = ImageDraw.Draw(base)
        render_text_with_emoji(base, canv, (80, 200), wrap(font, text[0], 220), font, 'white')
        render_text_with_emoji(base, canv, (290, 240), wrap(font, text[1], 320), font, 'white')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 21
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open('assets/expandingwwe/expandingwwe.jpg')
        font = ImageFont.truetype('assets/fonts/verdana.ttf', size=30)

        text = text.replace(', ', ',')

        if len(text.split(',')) < 5:
            a, b, c, d, e = 'you need, five items, for this, command, (split by commas)'.split(
                ',')
        else:
            a, b, c, d, e = text.split(',', 4)

        a, b, c, d, e = [wrap(font, i, 225).strip() for i in [a, b, c, d, e]]

        canvas = ImageDraw.Draw(base)
        canvas.text((5, 5), a, font=font, fill='Black')
        canvas.text((5, 205), b, font=font, fill='Black')
        canvas.text((5, 410), c, font=font, fill='Black')
        canvas.text((5, 620), d, font=font, fill='Black')
        canvas.text((5, 825), e, font=font, fill='Black')

        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 22
0
    async def sign(self, ctx, *, text: commands.clean_content(fix_channel_mentions = True)):
        """ making creative command descriptions is hard tbh """
        if len(text) > 120:
            return await ctx.send(f'Sorry! Text needs to be less than 120 characters long. **({len(text)}/120)**')

        async with ctx.channel.typing():
            with BytesIO() as b:
                font = ImageFont.truetype("assets/generators/sign/verdana.ttf", 30)
                final_text = textutils.wrap(font, text, 330)

                lines = final_text.split('\n')
                l_adjust = 200 if len(lines) < 4 else 228

                base = Image.open("assets/generators/sign/template.png").convert("RGBA")
                txtO = Image.new("RGBA", base.size, (255, 255, 255, 0))

                canv = ImageDraw.Draw(txtO)
                canv.text((l_adjust, 200), final_text, font=font, fill="Black")

                txtO = txtO.rotate(12.5, resample=Image.BICUBIC)

                out = Image.alpha_composite(base, txtO)

                out.save(b, "PNG")
                b.seek(0)
                await ctx.send(file=discord.File(b, filename="sign.png"))
Exemplo n.º 23
0
    async def generate(self, request, avatars, text, usernames):
        base = Image.open('assets/plan/plan.png').convert('RGBA')
        font = ImageFont.truetype(font='assets/fonts/sans.ttf', size=16)
        canv = ImageDraw.Draw(base)

        words = text.split(', ')

        if len(words) != 3:
            words = [
                'you need three items for this command',
                'and each should be split by commas',
                'Example: pls plan 1, 2, 3'
            ]

        words = [wrap(font, w, 120) for w in words]

        a, b, c = words

        canv.text((190, 60), a, font=font, fill='Black')
        canv.text((510, 60), b, font=font, fill='Black')
        canv.text((190, 280), c, font=font, fill='Black')
        canv.text((510, 280), c, font=font, fill='Black')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(body=b, content_type='image/png')
Exemplo n.º 24
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/plan/plan.bmp')).convert('RGBA')
        font = self.assets.get_font('assets/fonts/sans.ttf', size=16)
        canv = ImageDraw.Draw(base)

        words = text.split(', ')

        if len(words) != 3:
            words = ['you need three items for this command',
                     'and each should be split by commas',
                     'Example: pls plan 1, 2, 3']

        words = [wrap(font, w, 120) for w in words]

        a, b, c = words

        canv.text((190, 60), a, font=font, fill='Black')
        canv.text((510, 60), b, font=font, fill='Black')
        canv.text((190, 280), c, font=font, fill='Black')
        canv.text((510, 280), c, 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')
Exemplo n.º 25
0
    def generate(self, avatars, text, usernames, kwargs):

        base = Image.open(
            self.assets.get('assets/garfield/garfield.png')).convert('RGB')
        no_entry = Image.open(self.assets.get(
            'assets/garfield/no_entry.png')).convert('RGBA').resize(
                (224, 224), Image.LANCZOS)
        font = self.assets.get_font('assets/fonts/arial.ttf', size=28)
        avatar = get_image(avatars[0]).resize((192, 192),
                                              Image.LANCZOS).convert('RGBA')
        avatar2 = avatar.copy().resize((212, 212),
                                       Image.LANCZOS).convert('RGBA')

        base.paste(avatar, (296, 219), avatar)
        base.paste(no_entry, (280, 203), no_entry)
        base.paste(avatar2, (40, 210), avatar2)

        draw = ImageDraw.Draw(base)
        render_text_with_emoji(base, draw, (15, 0),
                               wrap(font, text, base.width), font, 'black')

        b = BytesIO()
        base.save(b, format='png')
        b.seek(0)
        return send_file(b, mimetype='image/png')
Exemplo n.º 26
0
async def expandingwwe(request):
    base = Image.open("assets/expandingwwe/expandingwwe.jpg")
    font = ImageFont.truetype("assets/fonts/verdana.ttf", size=30)

    text = request.headers.get("text")
    text = text.replace(", ", ",")

    if len(text.split(",")) < 5:
        (
            a,
            b,
            c,
            d,
            e,
        ) = "you need, five items, for this, command, (split by commas)".split(",")
    else:
        a, b, c, d, e = text.split(",", 4)

    a, b, c, d, e = [wrap(font, i, 225).strip() for i in [a, b, c, d, e]]

    canvas = ImageDraw.Draw(base)
    canvas.text((5, 5), a, font=font, fill="Black")
    canvas.text((5, 205), b, font=font, fill="Black")
    canvas.text((5, 410), c, font=font, fill="Black")
    canvas.text((5, 620), d, font=font, fill="Black")
    canvas.text((5, 825), e, font=font, fill="Black")
    return gen_file_response(base, {"format": "png"})
Exemplo n.º 27
0
async def cry(request):
    base = Image.open("assets/cry/cry.bmp")
    font = ImageFont.truetype("assets/fonts/tahoma.ttf", size=20)
    canv = ImageDraw.Draw(base)
    text = request.headers.get("text")
    text = wrap(font, text, 180)
    render_text_with_emoji(base, canv, (382, 80), text, font=font, fill="Black")
    return gen_file_response(base, {"format": "png"})
Exemplo n.º 28
0
async def doglemon(request):
    base = Image.open("assets/doglemon/doglemon.bmp")
    font = ImageFont.truetype("assets/fonts/medium.woff", size=30)
    canv = ImageDraw.Draw(base)
    text = request.headers.get("text")
    try:
        lemon, dog = text.replace(" ,", ",", 1).split(",", 1)
    except ValueError:
        lemon = "Text that is not seperated by comma"
        dog = "Dank Memer"
    lemon = wrap(font, lemon, 450)
    dog = wrap(font, dog, 450)
    render_text_with_emoji(base, canv, (850, 100), lemon[:180], font=font, fill="Black")
    render_text_with_emoji(base, canv, (500, 100), dog[:200], font=font, fill="White")

    base = base.convert("RGB")
    return gen_file_response(base, {"format": "png"})
Exemplo n.º 29
0
    def generate(self, avatars, text, usernames, kwargs):
        base = Image.open(self.assets.get('assets/theoffice/theoffice.png'))
        font = self.assets.get_font('assets/fonts/verdana.ttf', size=28)
        canv = ImageDraw.Draw(base)

        left, right = text.replace(', ', ',').split(',', 2)

        render_text_with_emoji(base, canv, (125, 200), wrap(font, left, 200),
                               font, 'white')
        render_text_with_emoji(base, canv, (420, 250), wrap(font, right, 200),
                               font, 'white')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')
Exemplo n.º 30
0
    def generate(self, avatars, text, usernames, kwargs):
        text = text.replace(', ', ',').split(',')
        if len(text) != 2:
            text = ['you should add two things split by commas', 'idiot']
        base = Image.open(self.assets.get('assets/justpretending/justpretending.jpg'))
        font = self.assets.get_font('assets/fonts/verdana.ttf', size=24)
        canv = ImageDraw.Draw(base)
        render_text_with_emoji(base, canv, (678, 12), wrap(font, text[0], 320), font, 'black')
        render_text_with_emoji(base, canv, (9, 800), wrap(font, text[1], 100), font, 'black')
        render_text_with_emoji(base, canv, (399, 808), wrap(font, text[1], 100), font, 'black')
        render_text_with_emoji(base, canv, (59, 917), wrap(font, text[1], 100), font, 'black')
        render_text_with_emoji(base, canv, (425, 910), wrap(font, text[1], 100), font, 'black')

        base = base.convert('RGB')
        b = BytesIO()
        base.save(b, format='jpeg')
        b.seek(0)
        return send_file(b, mimetype='image/jpeg')