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')
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')
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')
async def ify(ctx, scale, path, file_name, *args): """Command to paste a face on top of faces in an inputed image using facial recognition Args: - ctx: context that the command occured use this to access the message and other attributes - args: arguments of the message - scale: specified scale for the faces - path: face image path - file_name: output file name """ channel = ctx.channel url = over.get_image_url_args(ctx, args[0], 1, 0) if url == 0: # invalid image await channel.send(embed=discord.Embed(description="Invalid image", color=discord.Color.red())) return else: output = paste_on_face(Path(path), url, scale) # if there were no faces found then send error if output == 0: await channel.send(embed=discord.Embed( description='No faces found, please input another image', color=discord.Color.red())) return output.save(file_name) try: message = await channel.send(file=discord.File(file_name)) track_command(ctx.author.id, message) except: await channel.send(embed=discord.Embed(description="Image too large", color=discord.Color.red())) os.remove(file_name)
async def zoomcam(ctx, path, file_name, *args): """Command to paste a a zoomer in the corner of an image Args: - ctx: context that the command occured use this to access the message and other attributes - path: zoomer image path - file_name: output file name - args: arguments of the message """ channel = ctx.channel url = over.get_image_url_args(ctx, args[0], 1, 0) if url == 0: # invalid image await channel.send(embed=discord.Embed(description="Invalid image", color=discord.Color.red())) return else: output = over.paste_in_streamer_corner(Path(path), url) if output == 0: await channel.send(embed=discord.Embed( description= "Encountered issue converting image to RGBA, please try a different image", color=discord.Color.red())) return output.save(file_name) try: message = await channel.send(file=discord.File(file_name)) track_command(ctx.author.id, message) except: await channel.send(embed=discord.Embed(description="Image too large", color=discord.Color.red())) os.remove(file_name)
async def ify(ctx, scale, path, file_name, *args): """Command to paste a face on top of faces in an inputed image using facial recognition Args: - ctx: context that the command occured use this to access the message and other attributes - args: arguments of the message - scale: specified scale for the faces - path: face image path - file_name: output file name """ channel = ctx.channel async with channel.typing(): url = over.get_image_url_args(ctx.message, args[0], 1, 0) if url == 0: # invalid image # no input given, try to use previous bot output if bot_last_command[ctx.author.id] is not None: message = bot_last_command[ctx.author.id] url = over.get_image_url(message, 0) else: await channel.send(embed=discord.Embed( description= "No previous bot command to pull from. Please specify a valid image.", color=discord.Color.red())) return try: output = paste_on_face(Path(path), url, scale) except: await channel.send(embed=discord.Embed( description='Unidentified Image, try a different image', color=discord.Color.red())) # if there were no faces found then send error if output == 0: await channel.send(embed=discord.Embed( description='No faces found, please input another image', color=discord.Color.red())) return output.save(file_name) try: message = await channel.send(file=discord.File(file_name)) track_command(ctx.author.id, message) except: await channel.send(embed=discord.Embed( description="Image too large", color=discord.Color.red())) os.remove(file_name)
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")
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')
async def zoomcam(ctx, path, file_name, *args): """Command to paste a a zoomer in the corner of an image Args: - ctx: context that the command occured use this to access the message and other attributes - path: zoomer image path - file_name: output file name - args: arguments of the message """ channel = ctx.channel async with channel.typing(): url = over.get_image_url_args(ctx.message, args[0], 1, 0) if url == 0: # invalid image # no input given, try to use previous bot output if bot_last_command[ctx.author.id] is not None: message = bot_last_command[ctx.author.id] url = over.get_image_url(message, 0) else: await channel.send(embed=discord.Embed( description= "No previous bot command to pull from. Please specify a valid image.", color=discord.Color.red())) return output = over.paste_in_streamer_corner(Path(path), url) if output == 0: await channel.send(embed=discord.Embed( description= "Encountered issue converting image to RGBA, please try a different image", color=discord.Color.red())) return output.save(file_name) try: message = await channel.send(file=discord.File(file_name)) track_command(ctx.author.id, message) except: await channel.send(embed=discord.Embed( description="Image too large", color=discord.Color.red())) os.remove(file_name)
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')