Cosmetic enhancement for embbeded covers
Diegus83 opened this issue · 1 comments
I noticed that the book covers in the library appear stretched in the previews and when you download them, but appear in the correct aspect ratio (1:1) in the web player.
Update: I realized we could resize the cover with ffmpeg and not create a new dependency. 510x510px seems reasonable since the original image is 510px wide and there isn't any gain in scaling it up. Declaring a specific quality seems necessary, otherwise the resulting image is extremely compressed.
ffmpeg -y -i cover.jpg -vf scale=510:510 -qmin 1 -qscale:v 1 cover.jpg
Most players expect the embedded art to be square (like it would be in a regular music file). It is an easy fix but depends on adding the Python Image Library to resize the cover.
from PIL import Image
img = Image.open('cover.jpg')
img = img.resize(((img.size[0]),(img.size[0])), Image.LANCZOS)
img.save('cover.jpg')
Would you be interested in merging this and resizing all covers by default?
Or maybe making it a new argument? eg. -r "Resize cover image to 1:1 aspect ratio"
To avoid having a fixed image width, can you do something like
ffmpeg -y -i cover.jpg -vf scale=iw:iw -qmin 1 -qscale:v 1 cover.jpg
Please note that ffmpeg is not strictly a requirement unless merging is specified. If it is is not available, let the command fail gracefully and continue.
Otherwise, it sounds good to me. I don't think there's a need to add a new argument just for this.