mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-10-29 12:54:42 +00:00
fix: image aspect ratio
This commit is contained in:
1 parent
f6f66c571c
commit
eb4c65de83
1 file changed
+1
-5
@@ -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