Extract images from FLAC

Started by user2014, May 29, 2018, 11:14:07 AM

Previous topic - Next topic

user2014

Hello,
I'd like to extract the embedded cover-images from FLAC-files.
I tried several combinations: -b, -previewimage, -thumbnailimage, ....
I got jpg-files with a reasonable filesize - but they area unreadable.
When I try to open them with Explorer, Gimp, .... I get the message that they are somehow damaged / corrupted - unable to open them.

Any ideas ? Do I need additional command line options ?

Thank you
Erwin



Phil Harvey

Hi Erwin,

Try this:

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

(this is one of the examples in the application documentation)

- 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 ($).

StarGeek

Quote from: user2014 on May 29, 2018, 11:14:07 AM
I tried several combinations: -b, -previewimage, -thumbnailimage, ....
I got jpg-files with a reasonable filesize - but they area unreadable.

If you are on Windows, do not use Powershell, use CMD.
Details on Powershell problem.
Previous thread on similar operation.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

user2014

Hi Phil,

thanks for the ultra fast reply.
With -preview:all the images are now readable.
Is there also something like -preview:First, -preview:Second, .... to get a single/individual image instead of all.
E.g. there can be a front-cover, a back-cover, .... embedded in a FLAC-file.

Bye
Erwin

Phil Harvey

You can extract individual or multiple previews by replacing -preview:all with the tag name of the image you want to extract.  If multiple images have the same tag name, then you can use -4:TAG, -copy1:TAG, -copy2:TAG etc to extract the one(s) you want.

- 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 ($).

user2014

Hi Phil,

It's getting better ....

I have a FLAC-file with 3 pictures embedded.
This is the result of -a :

Picture Type                    : Front Cover
Picture MIME Type               : image/jpeg
Picture Description             :
Picture Width                   : 970
Picture Height                  : 951
Picture Bits Per Pixel          : 24
Picture Indexed Colors          : 0
Picture Length                  : 361493
Picture                         : (Binary data 361493 bytes, use -b option to extract)
Picture Type                    : Back Cover
Picture MIME Type               : image/jpeg
Picture Description             :
Picture Width                   : 932
Picture Height                  : 1024
Picture Bits Per Pixel          : 24
Picture Indexed Colors          : 0
Picture Length                  : 217329
Picture                         : (Binary data 217329 bytes, use -b option to extract)
Picture Type                    : Extra
Picture MIME Type               : image/jpeg
Picture Description             :
Picture Width                   : 253
Picture Height                  : 253
Picture Bits Per Pixel          : 24
Picture Indexed Colors          : 0
Picture Length                  : 16291
Picture                         : (Binary data 16291 bytes, use -b option to extract)

With
-Picture I got the first picture
-copy1:Picture the second picture
-copy2:Picture the third picture
but in a different order (compared to -a results) !!!!
The first picture with length 16291 then the second with length 361493 and then the last one with 217329 bytes.
With -a this is the third, the first and then the second.

Am I doing something wrong ?
I want to get them in the correct order (-a) or selecting them by tag PictureType - Front Cover, .....
(I'm calling exiftool from C# with -stay_open and -execute.)

Thanks.

PS: I also need to change/write one tag (not the picture tag) in FLAC.
When will this be possible ?

Bye
Erwin

Phil Harvey

Hi Erwin,

Add -G4 -a when extracting to see the ordering of the copy numbers.

- 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 ($).

user2014

Thanks Phil,

now all FLAC-picture reading problems are solved.
It's not an easy and obvious solution with -G4 -copy1:TAG....
I would recommend adding the reading of multiple pictures to the examples section.
Maybe I have missed the -G4 and -copy:TAG options in the documentation .....

My last question - writing of tags in FLAC-files ?
I need to add an ID (reference key) to each FLAC-file.

Bye
Erwin

Phil Harvey

The -G option and -GROUP:TAG options work for any family of groups.  Family 4 is the copy number.

FLAC is currently read-only by ExifTool.

- 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 ($).

bodacious

How would I go about recursively searching a directory for flac files matching a pattern of say "01 -*.flac"—so that I would only be creating one image file per album—then exporting that image, to the same directory as the file it came from, with filename of my choosing, say "cover_extracted.ext"? Perhaps even extracting all images from the flac, and using a prefix.

Thanks

Phil Harvey

exiftool -r -ext flac -if "$filename =~ /^01 -/" -W %d/cover_extracted%-c.%s -preview:all -a -b DIR

- 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 ($).

bodacious

Thanks. I'm not sure why but the files fail the condition. Probably something obvious. I've written a little script around metaflac now, but I will see if I can figure the exiftool solution out.

Phil Harvey

Change to single quotes if you are on Mac or Linux.

- 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 ($).

bodacious