audio - How to add album art to mp3 file using python 3? -


i wondering module use setting image album art particular mp3 file. mutagen seemed popular choice, doesn't seem work on python 3 , can't find documentation.

here's modified version of code use. want change example.mp3 , cover.jpg (and perhaps mime type too):

import eyed3  audiofile = eyed3.load('example.mp3') if (audiofile.tag == none):     audiofile.inittag()  audiofile.tag.images.set(3, open('cover.jpg','rb').read(), 'image/jpeg')  audiofile.tag.save() 

tag.images.set() takes 3 arguments:

  • picture type: type of image is. 3 code front cover art. can find them here.
  • image data: binary data of image. in example, load in using open().read().
  • mime type: type of file binary data is. if it's jpg file, you'll want image/jpeg, , if it's png file, you'll want image/png.

Comments