fix: image aspect ratio

This commit is contained in:
cwilvx
2024-11-01 09:56:33 +03:00
parent f6f66c571c
commit eb4c65de83
+2 -6
View File
@@ -228,16 +228,12 @@ class MixesPlugin(Plugin):
) as f:
f.write(res.content)
# resize to 256x256
# resize to 256px width while maintaining aspect ratio
img = Image.open(f"{Paths.get_md_mixes_img_path()}/{artist.artisthash}.jpg")
aspect_ratio = img.width / img.height
newwidth = 256
if aspect_ratio > 1:
newheight = int(256 / aspect_ratio)
else:
newheight = 256
newheight = int(256 / aspect_ratio)
img = img.resize((newwidth, newheight), Image.LANCZOS)
img.save(f"{Paths.get_sm_mixes_img_path()}/{artist.artisthash}.jpg")