ExifTool Forum

ExifTool => Newbies => Topic started by: samuel.gallard on January 20, 2012, 03:07:23 AM

Title: Extract a specific image from a mp3
Post by: samuel.gallard on January 20, 2012, 03:07:23 AM
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
Title: Re: Extract a specific image from a mp3
Post by: Phil Harvey on January 20, 2012, 07:24:53 AM
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
Title: Re: Extract a specific image from a mp3
Post by: samuel.gallard on January 20, 2012, 07:58:28 AM
Hi Phil,

I have tested your solution and it works well !

Thanks you for your quick reply.

I really appreciate your help.

Samuel
Title: Re: Extract a specific image from a mp3
Post by: trudge on January 15, 2019, 03:19:24 PM
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.
Title: Re: Extract a specific image from a mp3
Post by: Phil Harvey on January 15, 2019, 09:48:18 PM
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