pythonflacalbumart

How to delete the covert art of a flac file in python


I have some flac songs, they all have different cover arts. I really want to remove or change the covert art with my own .png

What I have tried so far:

from mutagen import File
from PIL import Image

img = Image.open('art.png')
file = File('ZAYN - PILLOWTALK.flac')

file.pictures[1] = img

file.save()

But have failed to do so.

Thx in advance.


Solution

  • After some research, found that mutagen.flac.pictures[0].data is a byte type, so I assigned it with an empty byte. For the code here it goes.

    from mutagen.flac import FLAC
    
    audio = FLAC("ZAYN - PILLOWTALK.flac")
    audio.pictures[0].data = b''
    audio.save()