mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix: image aspect ratio
This commit is contained in:
@@ -228,16 +228,12 @@ class MixesPlugin(Plugin):
|
|||||||
) as f:
|
) as f:
|
||||||
f.write(res.content)
|
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")
|
img = Image.open(f"{Paths.get_md_mixes_img_path()}/{artist.artisthash}.jpg")
|
||||||
aspect_ratio = img.width / img.height
|
aspect_ratio = img.width / img.height
|
||||||
|
|
||||||
newwidth = 256
|
newwidth = 256
|
||||||
|
|
||||||
if aspect_ratio > 1:
|
|
||||||
newheight = int(256 / aspect_ratio)
|
newheight = int(256 / aspect_ratio)
|
||||||
else:
|
|
||||||
newheight = 256
|
|
||||||
|
|
||||||
img = img.resize((newwidth, newheight), Image.LANCZOS)
|
img = img.resize((newwidth, newheight), Image.LANCZOS)
|
||||||
img.save(f"{Paths.get_sm_mixes_img_path()}/{artist.artisthash}.jpg")
|
img.save(f"{Paths.get_sm_mixes_img_path()}/{artist.artisthash}.jpg")
|
||||||
|
|||||||
Reference in New Issue
Block a user