예제 #1
0
async def saturate(ctx, *args):
    """Command to saturate a given image by a given factor

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
        - *args: arguments passed into the command (in this case the pixelation factor)
    """
    channel = ctx.channel
    url = overlay.get_image_url_args(ctx, args, 2, 1)
    try:
        factor = float(args[0])
    except:
        await channel.send(embed=discord.Embed(
            description="Invalid Parameters", color=discord.Color.red()))
        return
    if url == 0:
        await channel.send(embedd=discord.Embed(description="Invalid Image",
                                                color=discord.Color.red()))
        return
    output = filters.saturate_image(overlay.url_to_image(url), factor)
    output.save('saturate.png')
    try:
        message = await channel.send(file=discord.File('saturate.png'))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
    custom_meme.track_command(ctx.author.id, message)
    os.remove('saturate.png')
예제 #2
0
async def intensify(ctx, *args):
    """Command to intensify inputed image by the inputed factor

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
        - *args: arguments passed in with the command
    """
    channel = ctx.channel
    try:
        factor = float(args[0])
        url = overlay.get_image_url_args(ctx, args, 2, 1)
    except:
        factor = 2  # default if no factor specified
        url = overlay.get_image_url_args(ctx, args, 1, 0)
    if url == 0:  # invalid image
        await channel.send(embed=discord.Embed(description="Invalid image",
                                               color=discord.Color.red()))
        return
    output = filters.intensify_image(overlay.url_to_image(url), factor)
    if output == 0:  # if factor < 0
        await channel.send(embed=discord.Embed(description="Invalid factor",
                                               color=discord.Color.red()))
        return
    # save and send image
    output.save('intensify.png')
    try:
        message = await channel.send(file=discord.File('intensify.png'))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
    custom_meme.track_command(ctx.author.id, message)
    os.remove('intensify.png')
예제 #3
0
async def meme_generator(ctx, *args):
    """Command to generate memes with top and bottom text

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
        - *args: arguments passed in with the command
    """
    channel = ctx.channel
    url = overlay.get_image_url_args(ctx.message, args, 3, 2)
    if url == 0:  # invalid image
        await channel.send(embed=discord.Embed(description="Invalid image",
                                               color=discord.Color.red()))
        return
    else:
        output = overlay.paste_text_top_bottom(args[0], args[1],
                                               overlay.url_to_image(url))
    output.save('meme.png')
    try:
        message = await channel.send(file=discord.File('meme.png'))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
        return
    custom_meme.track_command(ctx.author.id, message)
    os.remove('meme.png')
예제 #4
0
async def mirror(ctx, *args):
    """Command to mirror given image on the inputted axis

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
        - *args: arguments passed in to the command (in this case either the X axis or Y axis)
    """
    channel = ctx.channel
    try:
        url = overlay.get_image_url_args(ctx.message, args, 2, 1)
        axis = args[0]
    except:
        await channel.send(embed=discord.Embed(description="Invalid input",
                                               color=discord.Color.red()))
        return
    if axis != "x" and axis != "y" and axis != "X" and axis != "Y":
        await channel.send(
            embed=discord.Embed(description="Invalid axis, please use x or y",
                                color=discord.Color.red()))
        return
    if axis == "x" or axis == "X":
        output = filters.mirror_x(overlay.url_to_image(url))
        output.save("mirror_x.png")
        try:
            message = await channel.send(file=discord.File("mirror_x.png"))
        except:
            message = await channel.send(embed=discord.Embed(
                description="Image too large", color=discord.Color.red()))
            return
        custom_meme.track_command(ctx.author.id, message)
        os.remove("mirror_x.png")
        return
    if axis == "y" or axis == "Y":
        output = filters.mirror_y(overlay.url_to_image(url))
        output.save("mirror_y.png")
        try:
            message = await channel.send(file=discord.File("mirror_y.png"))
        except:
            message = await channel.send(embed=discord.Embed(
                description="Image too large", color=discord.Color.red()))
            return
        custom_meme.track_command(ctx.author.id, message)
        os.remove("mirror_y.png")
예제 #5
0
async def noise_filter(ctx):
    """Command to apply a noise filter on the inputted image

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
    """
    channel = ctx.channel
    url = overlay.get_image_url(ctx, 7)
    if url == 0:
        await channel.send(embed=discord.Embed(description="Invalid Image",
                                               color=discord.Color.red()))
        return
    output = filters.scramble_pixels(overlay.url_to_image(url))
    output.save('noise.png')
    try:
        message = await channel.send(file=discord.File('noise.png'))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
    custom_meme.track_command(ctx.author.id, message)
    os.remove('noise.png')
예제 #6
0
async def highlight_edge(ctx, *args):
    """Command to apply an edge highlighting algorithm to a given image

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
    """
    channel = ctx.channel
    url = overlay.get_image_url_args(ctx, args, 1, 0)
    if url == 0:
        await channel.send(embed=discord.Embed(description="Invalid Image"),
                           color=discord.Color.red())
        return
    output = filters.highlight_image(overlay.url_to_image(url))
    output.save('highlighted.png')
    try:
        message = await channel.send(file=discord.File('highlighted.png'))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
    custom_meme.track_command(ctx.author.id, message)
    os.remove('highlighted.png')
예제 #7
0
async def make_okay(ctx):
    """Command to turn a given image into a video where marius says 'okay' in the background

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
    """
    channel = ctx.channel
    url = overlay.get_image_url(ctx, 6)
    if url == 0:
        await channel.send(embed=discord.Embed(description="Invalid Image",
                                               color=discord.Color.red()))
        return
    clip = filters.make_okay_clip(overlay.url_to_image(url))
    clip.write_videofile("okay.mp4", audio="sfx/okayturnedupto8.mp3", fps=24)
    try:
        message = await channel.send(file=discord.File("okay.mp4"))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
    custom_meme.track_command(ctx.author.id, message)
    os.remove("okay.mp4")
예제 #8
0
async def custom_edge_highlight(ctx, *args):
    """Command to highlight an image's edges and turn them into a given color

       Args:
        - ctx: context that the command occured use this to access the message and other attributes
        - *args: arguments passed in with the command (in this case the RGB values for the edge color)
    """
    channel = ctx.channel
    try:
        red = int(args[0])
        green = int(args[1])
        blue = int(args[2])
    except:
        await channel.send(embed=discord.Embed(
            description="Invalid Parameters", color=discord.Color.red()))
        return
    url = overlay.get_image_url_args(ctx.message, args, 4, 3)
    if url == 0:
        await channel.send(embed=discord.Embed(description="Invalid Image",
                                               color=discord.Color.red()))
        return
    output = filters.custom_edge_highlight_image(overlay.url_to_image(url),
                                                 red, green, blue)
    if output == 0:  #if the RGB values are invalid
        await channel.send(embed=discord.Embed(
            description=
            "Invalid RGB Values, please input numbers between 0-255",
            color=discord.Color.red()))
        return
    output.save('custom_highlight.png')
    try:
        message = await channel.send(file=discord.File('custom_highlight.png'))
    except:
        message = await channel.send(embed=discord.Embed(
            description="Image too large", color=discord.Color.red()))
        return
    custom_meme.track_command(ctx.author.id, message)
    os.remove('custom_highlight.png')