Removing all embedded images from mp3

Post Reply
ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Removing all embedded images from mp3

Post by ffx » Wed Jul 25, 2012 11:28 am

Hi,

I wonder if it's possible to remove all embedded images from a mp3 file, using the getid3 lib.
Is there a functionality for this? And is it documented?

My first approach was to write a new attached_image[0] using a spacer.gif, but without success.

Please help! Thanks.

James Heinrich
getID3() v1 developer
Posts: 1471
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Removing all embedded images from mp3

Post by James Heinrich » Wed Jul 25, 2012 1:31 pm

It would be a matter of reading the existing tags into an array, removing the bits you don't want (e.g. images) and then writing it back to the file.

I don't have a prepared example for this, but there are two generic writing demo files (demo.write.php and demo.simple.write.php).

ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by ffx » Wed Jul 25, 2012 3:22 pm

Well, there are images inside, but I cannot find any "attached_image" or "img" inside the analysis array.

James Heinrich
getID3() v1 developer
Posts: 1471
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Removing all embedded images from mp3

Post by James Heinrich » Wed Jul 25, 2012 3:24 pm

Take a peek at the file with the included demo.browse.php (in your browser) and you should be able to see where the images are. If they don't show up in demo.browse.php then please send me a sample file.

ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by ffx » Fri Jul 27, 2012 12:14 am

James Heinrich wrote:Take a peek at the file with the included demo.browse.php (in your browser) and you should be able to see where the images are. If they don't show up in demo.browse.php then please send me a sample file.
Tried this, could not find any picture. Finally I am removing the complete id3v2 tag executing the apt-get package "id3v2" with php-exec(). By removing theid3v2 tag, the embedded images also disappeared.

Maybe it would be very helpful, if getid3 had some functionality like "removeTag()" and "removeImages()"... What do you think about it?

James Heinrich
getID3() v1 developer
Posts: 1471
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Removing all embedded images from mp3

Post by James Heinrich » Fri Jul 27, 2012 1:15 am

ffx wrote:Tried this, could not find any picture.
Then I would be particularly interested in a copy of that sample file (from before the tags were removed, obviously). I suspect the image is embedded in some proprietary container, but I'd like to see where and how. What software are you using that sees the picture?

If getID3() doesn't see the image to begin with the any function like RemoveImage wouldn't work. Removing all tags would work, but then you're just guessing.
ffx wrote:Maybe it would be very helpful, if getid3 had some functionality like "removeTag()"
write.id3v2.php does contain the function RemoveID3v2()
write.id3v1.php does contain the function RemoveID3v1()
write.lyrics3.php does contain the function DeleteLyrics3()
write.apetag.php does contain the function DeleteAPEtag()
write.real.php does contain the function RemoveReal()
write.metaflac.php does contain the function DeleteMetaFLAC()
write.vorbiscomment.php does contain the function DeleteVorbisComment()

As with any file-altering functions, use with care.

ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by ffx » Mon Jul 30, 2012 10:56 am

Ok, thanks for the info.

So a correct code would be like this?

Code: Select all

                getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.id3v2.php', __FILE__, true);
                $tagwriter = new getid3_writetags;
                $tagwriter->filename = $pfad . $file;
                $tagwriter->RemoveID3v2();
                if ($tagwriter->WriteTags()) {
                    if (!empty($tagwriter->warnings)) {
                        $errors .= "Warnungen bei idv2-Löschvorgang: ".implode(', ', $tagwriter->warnings)."<br />";
                    }
                } else {
                    $errors .= "Fehler bei idv2-Löschvorgang: " . implode(', ', $tagwriter->errors) . "<br />";
                    $errNum++;
                }

ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by ffx » Mon Jul 30, 2012 11:04 am

Oh sorry, this should work:

Code: Select all

                getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.id3v2.php', __FILE__, true);
                $tagwriter = new getid3_write_id3v2;
                $tagwriter->filename = $pfad . $file;
                if ($tagwriter->RemoveID3v2()) {
                    if (!empty($tagwriter->warnings)) {
                        //$errors .= "Warnungen bei idv2-Löschvorgang ".implode(', ', $tagwriter->warnings)."<br />";
                    }
                } else {
                    $errors .= "Fehler bei idv2-Löschvorgang: " . implode(', ', $tagwriter->errors) . "<br />";
                    $errNum++;
                }

ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by ffx » Mon Jul 30, 2012 11:10 am

Ok, one last question:

I now first remove the id3v2 tag using the code from the last post, and then I write the basic tag data again.
Can I do this in one step, so the mp3 file is opened and written only once: open, remove id3v2, set up tags and writing?

James Heinrich
getID3() v1 developer
Posts: 1471
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Removing all embedded images from mp3

Post by James Heinrich » Mon Jul 30, 2012 11:49 am

Yes. By default if the new tag is smaller or equal to the size of the existing tag then the new tag is padded to the length of the old one and just overwrites the existing tag data in one step. In the case where you have a particularly large ID3v2 tag (e.g. with embedded images) that you want to replace with a much-smaller tag (i.e. just basic text artist/title/album) you can RemoveID3v2() and then WriteID3v2(), but that currently involves multiple file operations (including temp files) for each. You may be able to roll your own function that integrates all the file-handling (and tag-removal) logic from RemoveID3v2() into WriteID3v2() if this ability is critical to your application.

James Heinrich
getID3() v1 developer
Posts: 1471
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Removing all embedded images from mp3

Post by James Heinrich » Mon Jul 30, 2012 2:48 pm

James Heinrich wrote:
ffx wrote:Tried this, could not find any picture.
Then I would be particularly interested in a copy of that sample file (from before the tags were removed, obviously). I suspect the image is embedded in some proprietary container, but I'd like to see where and how. What software are you using that sees the picture?
Thanks for the sample file. It looks like there really is no image in the file. The ID3v2 tag has little data, but is padded to 128kB, so removing the ID3v2 tag should shrink the file by 128kB.

What software is showing you the image for this file? It's possible that it's showing some downloaded/online/linked image based on the filename and/or hash of the file, without actually embedding any image in the file itself.

ffx
User
Posts: 7
Joined: Wed Jul 25, 2012 11:25 am
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by ffx » Mon Jul 30, 2012 3:33 pm

Oh ok.

I used mp3 tag tools for Windows. Actually it does not show an image, but shrinks the header if I click "remove image". So it's maybe a problem of the encoder?
I will ask my client about the tagging process they make.

Thanks.

James Heinrich
getID3() v1 developer
Posts: 1471
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Removing all embedded images from mp3

Post by James Heinrich » Mon Jul 30, 2012 4:00 pm

ffx wrote:I used mp3 tag tools for Windows. Actually it does not show an image, but shrinks the header if I click "remove image". So it's maybe a problem of the encoder?
I will ask my client about the tagging process they make.
The "remove image" function most likely parses the tag, removes any images (in this case, none), reduces the padding to a smaller amount (1k and 4k are typical values), and rewrites the ID3v2 tag.

Padding in an ID3v2 tag is very good (prevents rewriting the entire file if you make the new tag even just 1 byte longer than it was before), but excessive padding (beyond a few kB) is just wasting space unless you expect to add an image or other large data into the tag later, and even then you'll most likely end up with wasted space if the padding is too large, or rewriting the file anyways if the padding is too small.

Kumarasen
User
Posts: 2
Joined: Tue Aug 07, 2012 2:57 pm
Are you a spambot?: no

Re: Removing all embedded images from mp3

Post by Kumarasen » Tue Aug 07, 2012 9:07 pm

When you download an mp3 file from web, usually it comes embedded with an album art image featuring the website’s address. This album art image is displayed when you view the mp3 file in windows explorer or when you play it in any media player. The album art image comes from either a hidden jpg file associated with the mp3 file or from the embedded image inside the mp3 file itself.
Delete The Album Art Images That Are Hidden in The Folder

To delete the hidden album art images, you need to make the hidden files visible on the windows explorer and then delete the images manually. Here’s the procedure,
1. Go to Start > Control Panel > Folder Options, select the View Tab. In the View tab, under Advanced Settings,
Enable the radio button that says, Show hidden files, folders, and drives
Uncheck the option that says, Hide protected operating system files

Click on Apply to save these settings. Now go to the folder that contains the mp3 files and find the hidden image files with the names like AlbumArt_{GUID}_Small.jpg, AlbumArt_{GUID}_Large.jpg, Folder.jpg etc. Delete all these files and the mp3 files will no longer display the album art.
Delete The Album Art Images Embedded in the MP3 Files

90% of the time, deleting the hidden image files in the mp3 folder will remove the associated album art. But sometimes the image is embedded inside the mp3 file. In this case you have to use an ID3 tag editor to remove them. One of the best and free one is, mp3tag .
Download mp3tag and open the mp3 file, whose album art you want to remove, in it. Then right click on the album art image displayed in the bottom left corner and click on Remove cover option. Repeat this for all the mp3 files that have the album art image embedded inside it.
Note – If you are on Linux, then you can use Picard instead of mp3tag.
______________________

Post Reply