Author Topic: Extract a specific image from a mp3  (Read 4094 times)

samuel.gallard

  • Newbie
  • *
  • Posts: 2
Extract a specific image from a mp3
« 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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14733
    • ExifTool Home Page
Re: Extract a specific image from a mp3
« Reply #1 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

samuel.gallard

  • Newbie
  • *
  • Posts: 2
Re: Extract a specific image from a mp3
« Reply #2 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

trudge

  • Jr. Member
  • **
  • Posts: 11
Re: Extract a specific image from a mp3
« Reply #3 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14733
    • ExifTool Home Page
Re: Extract a specific image from a mp3
« Reply #4 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).