I am trying to read the cover from an MP3 file with the following code.
import tkinter as tk
from PIL import Image, ImageTk
from io import BytesIO
import mutagen
from mutagen.id3 import APIC
root = tk.Tk()
image_bytes = mutagen.File('/Users/id3-sample.mp3')['APIC:'].data
image_stream = BytesIO(image_bytes)
img = ImageTk.PhotoImage(Image.open(image_stream))
tk.Label(root, image = img).pack()
But I get the following error message:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mutagen/_util.py", line 536, in __getitem__
return self.__dict[key]
builtins.KeyError: 'APIC:'