'How do I convert an image to a http/https url for python?

I've used pillow to generate an image combining two random images, such that a new image is generated each the code is ran, but i want the image to be a http/https url since it needs to be embedded in discord, which only supports http/https url's.



Solution 1:[1]

Using discord.File and attachement-url you will be able to send your generated images through an embed

You can try the following code:

    @commands.command(name="image")
    async def _image(self, ctx):
        image = Image.new("RGBA", size=(500, 500), color=(0, 0, 0))
        with BytesIO() as img_bin:
            image.save(img_bin, "PNG")
            img_bin.seek(0)
            file = discord.File(img_bin, filename="yourImage.png") 

        embed = discord.Embed(title="Embed", description="description")
        embed.set_image(url="attachment://yourImage.png")
        embed.set_thumbnail(url="attachment://yourImage.png")

        await ctx.send(embed=embed, file=file)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul