How to remove existing album art image from an Mp3 using eyed3 module

2.4k views Asked by At

I have been attempting to use the eyed3 module for tagging mp3 files, but unfortunately, I find the module documentation difficult to understand and was wondering if someone can help me?.. Documentation can be found at https://eyed3.readthedocs.io

I was trying to use it to remove existing album art image using:

import eyed3
x = eyed3.load('file_path')
x.tag._images.remove()
x.tag.save()

But when I run this code, it gives me the following error:

TypeError: remove() missing 1 required positional argument: 'description'

I am not sure where to find the above mentioned description to pass as a parameter. I have also looked at the source python file for eyed3 tagging, but based on investigating the code, I can't seem to find out what to pass for this argument description.

I attempted to pass an empty string as the argument, but although the script ran fine without any errors, it did not remove the album art image.

Please help.

2

There are 2 answers

2
JPeroutek On BEST ANSWER

After digging around a bit, description is literally just the description of the image. When you call x.tag.images you get an ImageAccessor object, which is basically just an iterable containing your images. If you cast x.tag.images to a list, you can see it contains 1 ImageFrame object (in my test case). When you call x.tag.images.remove(), eyed3 needs to know which image to remove, and it selects the image to remove based on the image description. You can get the descriptions of each image using something like this.

[y.description for y in x.tag.images]

Once you know the description of the image you want to remove, you should be able to pass it into the remove function, and that specific image will be removed.

>>> x.tag.images
<eyed3.id3.tag.ImagesAccessor object at 0x1053c8400>
>>> list(x.tag.images)
[<eyed3.id3.frames.ImageFrame object at 0x1050cc4a8>]
>>> x.tag.images.remove()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jperoutek/test_env/lib/python3.6/site-packages/eyed3/utils/__init__.py", line 170, in wrapped_fn
    return fn(*args, **kwargs)
TypeError: remove() missing 1 required positional argument: 'description'
>>> x.tag.images.remove('')
<eyed3.id3.frames.ImageFrame object at 0x1050cc4a8>
>>> x.tag.images
<eyed3.id3.tag.ImagesAccessor object at 0x1053c8400>
>>> list(x.tag.images)
[]
0
JJSIL Designer On

Your code:

    import eyed3
    x = eyed3.load('file_path')
    x.tag._images.remove()
    x.tag.save()

Try this:

    import eyed3
    x = eyed3.load('file_path')
    x.tag.images.remove('')
    x.tag.save()

works with me!