diff --git a/app/bot.py b/app/bot.py old mode 100755 new mode 100644 index 48190a40..a62b2242 --- a/app/bot.py +++ b/app/bot.py @@ -53,15 +53,18 @@ async def fix_cdn_url(ctx): @bot.listen("on_message") async def convert_heic_to_jpg(ctx): from cmagick import cmagick + import time + import tempfile if ctx.attachments: for attachment in ctx.attachments: if attachment.filename.lower().endswith(("heic", "tiff")): source_file = "/tmp/source" - jpg_file = "/tmp/converted.jpg" - await attachment.save(fp=source_file) + source_file, file_path = tempfile.mkstemp() + jpg_file = "/tmp/%s.jpg" % time.time() + await attachment.save(fp=file_path) - img = cmagick.convert(source_file, jpg_file) + img = cmagick.convert(file_path, jpg_file) try: await ctx.delete()