Skip to content

Commit

Permalink
Fix #142 by setting width, height and color depth
Browse files Browse the repository at this point in the history
  • Loading branch information
JVT038 committed Oct 5, 2024
1 parent 8ddab7a commit 29ac38f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion metatube/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,15 @@ def mergeaudiodata(data):
)
cover.save()
else:
from PIL import Image
from io import BytesIO
img = Image.open(BytesIO(data["image"]))
cover = Picture()
cover.data = data["image"]
cover.type = 3
cover.height = img.height
cover.width = img.width
cover.depth = self.modeToDepth().get(img.mode, 0)
cover.mime = data["cover_mime_type"]
cover.desc = 'Front cover'
if data["extension"] == 'FLAC':
Expand Down Expand Up @@ -593,4 +599,15 @@ def MKV(filename):

@staticmethod
def AVI(filename):
pass
pass

@staticmethod
def modeToDepth():
return {
'1': 1, # 1-bit pixels
'L': 8, # 8-bit grayscale
'P': 8, # 8-bit palette
'RGB': 24, # 24-bit (8 bits per channel)
'RGBA': 32, # 32-bit (8 bits per channel + alpha)
'CMYK': 32 # 32-bit (8 bits per channel)
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ youtube-search-python==1.6.6
spotipy==2.24.0
urllib3==2.2.2
deezer-python==6.1.1
lyricsgenius==3.0.1
lyricsgenius==3.0.1
pillow==10.4.0

0 comments on commit 29ac38f

Please sign in to comment.