10

I need to add ID3 cover art to some MP3 files. I need a command line tool (no GUI) but it seems that neither id3 nor id3v2 tools can do it. Any hint?

2 Answers 2

18

An excellent Python application that I routinely use to add cover art to mp3 files is the command line applicationeyeD3. This can be installed from a Terminal as follows:

sudo apt-get install eyed3

Here is an example of a command to add a cover image named cover.jpg to an mp3 file named test.mp3:

eyeD3 --add-image "cover.jpg:FRONT_COVER" test.mp3

See an example below of this at work on my own computer, adding a cover image to an mp3 otherwise empty of meta tags:

andrew@ilium~$ eyeD3 --add-image "cover.jpg:FRONT_COVER" test.mp3
test.mp3    [ 946.12 KB ]
-------------------------------------------------------------------------------
Adding image cover.jpg
Time: 01:00 MPEG1, Layer III    [ 128 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.4:
title: 
artist: 
album: 
album artist: None
track:      
FRONT_COVER Image: [Size: 95788 bytes] [Type: image/jpeg]
Description: 

Writing ID3 version v2.4
-------------------------------------------------------------------------------
andrew@ilium~$ 

There are many other options for adding images although I have given the basic syntax above. Below are these other options:

  --add-image IMG_PATH:TYPE[:DESCRIPTION]
                        Add or replace an image. There may be more than one
                        image in a tag, as long as the DESCRIPTION values are
                        unique. The default DESCRIPTION is ''. If PATH begins
                        with 'http[s]://' then it is interpreted as a URL
                        instead of a file containing image data. The TYPE must
                        be one of the following: OTHER, ICON, OTHER_ICON,
                        FRONT_COVER, BACK_COVER, LEAFLET, MEDIA, LEAD_ARTIST,
                        ARTIST, CONDUCTOR, BAND, COMPOSER, LYRICIST,
                        RECORDING_LOCATION, DURING_RECORDING,
                        DURING_PERFORMANCE, VIDEO, BRIGHT_COLORED_FISH,
                        ILLUSTRATION, BAND_LOGO, PUBLISHER_LOGO.

References:

2
  • 1
    This is really new to me! So far I've only found GUI tools or some MP3 encoder like lame. Thanks.
    – EnzoR
    Jun 20, 2016 at 13:19
  • Seconded, eyeD3 is the way to go. Feb 12, 2020 at 19:52
6

Here is a Python script that works for me. Run it with python script.py audiofile.mp3.

You will need mutagen; install it with sudo -H pip install mutagen.

from mutagen.mp3 import MP3
from mutagen.id3 import ID3, APIC, error
import sys
mp3file=sys.argv[1]
audio = MP3(mp3file, ID3=ID3)

try:
   audio.add_tags()
except error:
   pass

audio.tags.add(
   APIC(
      encoding=1,
      mime='image/png',
      type=3,
      desc=u'Cover',
      data=open('/path/to/artwork.png').read()
   )
)
audio.save()
3
  • 1
    Thanks for the hint. But this basically equals to "write the program yourself".
    – EnzoR
    Jun 19, 2016 at 21:12
  • 2
    I don't understand your comment. I have given you the program. What do you need to write yourself?
    – Jos
    Jun 19, 2016 at 21:14
  • If you read my question not as personal but as a general one, your answer, while a really good one, sounds like "No way, unless you write a program to do so (or youse Jos')".
    – EnzoR
    Jun 20, 2016 at 13:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .