Extract a specific image from a mp3

Started by samuel.gallard, January 20, 2012, 03:07:23 AM

Previous topic - Next topic

samuel.gallard

Hi,

I have a question about image extraction within a mp3 file. I could not find an answer in the FAQ and on this forum.

This is the output from the command "exiftool -ee myfile.mp3" :

Picture Mime Type               : image/jpg
Picture Type                    : Front Cover
Picture Description             : Magdalen Graal : Magdalen Graal
Picture                         : (Binary data 14486 bytes, use -b option to extract)
Picture Mime Type               : image/png
Picture Type                    : Lyricist
Picture Description             : http://www.jamendo.com
Picture                         : (Binary data 6889 bytes, use -b option to extract)
Picture Mime Type               : image/png
Picture Type                    : Other
Picture Description             : http://creativecommons.org/licenses/by-nc/3.0/
Picture                         : (Binary data 5145 bytes, use -b option to extract)

For example, I would like to extract only the "Front Cover" image. How could I do it ?

Thank you in advance
Regards

Samuel

Phil Harvey

Hi Samuel,

This isn't in the FAQ because it doesn't come up very often, but it is a bit tricky.   Here is how to do this:

1) exiftool -a -G4 "-picture*" myfile.mp3

2) exiftool -COPYNUM:picture -b myfile.mp3 > cover.png

where COPYNUM is the instance number group name given in brackets from the output of the 1st command (or just -picture if there is no copy number).

Note that you should choose an extension for the output image based on the PictureMimeType with the same copy number.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

samuel.gallard

Hi Phil,

I have tested your solution and it works well !

Thanks you for your quick reply.

I really appreciate your help.

Samuel

trudge

Thank you so much for this image-extraction advice. I'm building a web library of audio books, and would like to extract the cover image from an .mp3 file. This does the job nicely.

Phil Harvey

Note that it is now possible to easily extract all available images from a set of files. To do this for all files in a directory:

exiftool -W %d%f_%t%-c.%s -b -preview:all DIR

This will extract multiple images from each file if they exist.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).