Howto Write APIC Tag with Mutagen

1,844 views
Skip to first unread message

Joe

unread,
Jul 29, 2009, 5:28:46 AM7/29/09
to Quod Libet Development
Hi,

I am also working on exact the same Project. I want Amarok to write
the Cover to the Mp3 file. So they will show up on my mobile.

The following page describes how to write Tags with mutagen and
python:
http://www.mydigitallife.co.za/index.php?option=com_content&task=view&id=1046123&Itemid=43

I've managed to write Simple Tags like Artist or Title, but I was not
able to write the APIC tag.

Here is my Pythonscript:
import mutagen
from mutagen.id3 import APIC
audio = mutagen.File('alles.mp3')
imagedata = open('cover.png', 'rb').read()
pic = APIC(3, 'image/png', 3, 'Front cover', imagedata)
pic.HashKey
print audio

Maybe someone get this to work or can give some hints why this does
not work.

Best regards
Joe

Lukáš Lalinský

unread,
Jul 29, 2009, 6:13:43 AM7/29/09
to quod-libet-...@googlegroups.com
On Wed, Jul 29, 2009 at 11:28 AM, Joe<johannes...@googlemail.com> wrote:
> I am also working on exact the same Project. I want Amarok to write
> the Cover to the Mp3 file. So they will show up on my mobile.
> [...]

> Maybe someone get this to work or can give some hints why this does
> not work.

Hi Joe,

here is an example how to add cover art to an MP3 file:

from mutagen import id3, mp3
file = mp3.MP3('test.mp3')


imagedata = open('cover.png', 'rb').read()

file.tags.add(id3.APIC(3, 'image/png', 3, 'Front cover', imagedata))
file.save()

--
Lukas Lalinsky
lali...@gmail.com

Joe

unread,
Jul 29, 2009, 8:35:02 AM7/29/09
to Quod Libet Development
On 29 Jul., 12:13, Lukáš Lalinský <lalin...@gmail.com> wrote:
> On Wed, Jul 29, 2009 at 11:28 AM, Joe<johannes.dielm...@googlemail.com> wrote:
> > I am also working on exact the same Project. I want Amarok to write
> > the Cover to the Mp3 file. So they will show up on my mobile.
> > [...]
> > Maybe someone get this to work or can give some hints why this does
> > not work.
>
> Hi Joe,
>
> here is an example how to add cover art to an MP3 file:
>
> from mutagen import id3, mp3
> file = mp3.MP3('test.mp3')
> imagedata = open('cover.png', 'rb').read()
> file.tags.add(id3.APIC(3, 'image/png', 3, 'Front cover', imagedata))
> file.save()
>
> --
> Lukas Lalinsky
> lalin...@gmail.com

Thanks for your quick reply.

My first post should have been a reply to:
http://groups.google.com/group/quod-libet-development/browse_thread/thread/264ce515346def7e?pli=1

Never mind. Your code works perfectly.
Reply all
Reply to author
Forward
0 new messages