FLAC: Extract muliple embedded images in JSON

Started by Erik Bachmann, October 27, 2019, 03:32:44 AM

Previous topic - Next topic

Erik Bachmann

Trying to dump ID3 meta data from a FLAC file using: exiftool.exe -ee  xx.flac

Picture Type                    : Front Cover
Picture MIME Type               : image/jpeg
Picture Description             :
Picture Width                   : 1000
Picture Height                  : 1000
Picture Bits Per Pixel          : 0
Picture Indexed Colors          : 0
Picture Length                  : 97353
Picture                         : (Binary data 97353 bytes, use -b option to extract)
Picture Type                    : Back Cover
Picture MIME Type               : image/jpeg
Picture Description             :
Picture Width                   : 566
Picture Height                  : 501
Picture Bits Per Pixel          : 0
Picture Indexed Colors          : 0
Picture Length                  : 63852
Picture                         : (Binary data 63852 bytes, use -b option to extract)


But with the -json option I only get one image as if -ee is ignored: exiftool.exe -ee  -json xx.flac


  "PictureType": "Back Cover",
  "PictureMIMEType": "image/jpeg",
  "PictureDescription": "",
  "PictureWidth": 566,
  "PictureHeight": 501,
  "PictureBitsPerPixel": 0,
  "PictureIndexedColors": 0,
  "PictureLength": 63852,
  "Picture": "(Binary data 63852 bytes, use -b option to extract)",


olball

Quote from: Erik Bachmann on October 27, 2019, 03:32:44 AM
But with the -json option I only get one image as if -ee is ignored: exiftool.exe -ee  -json xx.flac


JSON does not support duplicate tag names. So you can't get as in your example:

"PictureType": "Back Cover",
<snip>
"PictureType": "Front Cover",
<snip>


You need to add a -g or -G switch.
From the -json documentation:
Quote
tags with identical JSON names are suppressed. (-g4 may be used to ensure that all tags have unique JSON names.)

Erik Bachmann

QuoteJSON does not support duplicate tag names

True but it could be inserted as a list

  "Pictures": [{
    "PictureType": "Back Cover",
:--8<-----------
    "Picture": "(Binary data 63852 bytes, use -b option to extract)"
    },
    "PictureType": "Front Cover",
:--8<-----------
    "Picture": "(Binary data 63852 bytes, use -b option to extract)"
    }],

Erik Bachmann

Checked with the -g4 option:

[{
  "SourceFile": "xx.flac",
  "Unknown": {
    "ExifToolVersion": 11.73,
:---8<--------------------->8---
    "Disctotal": 1,
    "PictureType": "Back Cover",
:---8<--------------------->8---
    "Picture": "(Binary data 63852 bytes, use -b option to extract)",
    "Duration": "0:04:50"
  },
  "Copy1": {
    "PictureType": "Front Cover",
:---8<--------------------->8---
    "Picture": "(Binary data 97353 bytes, use -b option to extract)"
  }
}]

It's JSON all right, but not exactly elegant. Can't really figure out why "Unknown" should be a branch in it's own right. It is only the "Picture" part that is the doublet.

Phil Harvey

ExifTool uses "Unknown" for any group name that is missing.  For primary tags (ie. not copies) there is no family 4 group name, so "Unknown" is used instead.  Not very pretty I admit.

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