diff --git a/metatube/metadata.py b/metatube/metadata.py index 0ae252a..6bae469 100644 --- a/metatube/metadata.py +++ b/metatube/metadata.py @@ -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': @@ -593,4 +599,15 @@ def MKV(filename): @staticmethod def AVI(filename): - pass \ No newline at end of file + 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) + } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f467958..f485186 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +lyricsgenius==3.0.1 +pillow==10.4.0 \ No newline at end of file