ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: user2014 on May 29, 2018, 11:14:07 AM

Title: Extract images from FLAC
Post by: user2014 on May 29, 2018, 11:14:07 AM
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


Title: Re: Extract images from FLAC
Post by: Phil Harvey on May 29, 2018, 11:16:02 AM
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 (https://exiftool.org/exiftool_pod.html#READING-EXAMPLES))

- Phil
Title: Re: Extract images from FLAC
Post by: StarGeek on May 29, 2018, 11:20:20 AM
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 (https://exiftool.org/forum/index.php/topic,8137.0.html) problem.
Previous thread (https://exiftool.org/forum/index.php?topic=8504.0) on similar operation.
Title: Re: Extract images from FLAC
Post by: user2014 on May 29, 2018, 12:50:22 PM
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
Title: Re: Extract images from FLAC
Post by: Phil Harvey on May 29, 2018, 03:46:47 PM
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
Title: Re: Extract images from FLAC
Post by: user2014 on May 30, 2018, 12:28:58 PM
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
Title: Re: Extract images from FLAC
Post by: Phil Harvey on May 30, 2018, 12:47:44 PM
Hi Erwin,

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

- Phil
Title: Re: Extract images from FLAC
Post by: user2014 on May 30, 2018, 01:07:01 PM
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
Title: Re: Extract images from FLAC
Post by: Phil Harvey on May 30, 2018, 08:36:39 PM
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
Title: Re: Extract images from FLAC
Post by: bodacious on April 15, 2020, 08:55:19 AM
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
Title: Re: Extract images from FLAC
Post by: Phil Harvey on April 15, 2020, 01:28:06 PM
exiftool -r -ext flac -if "$filename =~ /^01 -/" -W %d/cover_extracted%-c.%s -preview:all -a -b DIR

- Phil
Title: Re: Extract images from FLAC
Post by: bodacious on April 16, 2020, 08:05:14 AM
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.
Title: Re: Extract images from FLAC
Post by: Phil Harvey on April 16, 2020, 08:18:42 AM
Change to single quotes if you are on Mac or Linux.

- Phil
Title: Re: Extract images from FLAC
Post by: bodacious on April 16, 2020, 09:08:01 AM
Ah ha! Thanks very much.