home :: hacks :: flac :: flac-image

RSS 0.91 feeds Subscribe and save over 75% off newsstand price!

car - 9
games - 2
hacks - 21
  flac - 4
  photo - 5
  slim - 3
journal - 155
misc - 5
news - 9
pomona - 2
rants - 6

For the biographers:

2005 - 2006 - 2007 - 2008 - 2009

Now playing

Décollage (Cristobal Paz & Leo di Giusto remix)
from Remixed by Bajofondo
at Monday, December 14, 2009 12:51 AM

How this works

Hot Live Webcam

Yes, really.

Recently from Google

from Richmond CA, searching for squeezebox blackberry plugin

from Seattle WA, searching for michael dickerson girlfriend fan site

How this works

Contact me

mikey@singingtree.com
4171622
mdickers47
mike.dickerson@pomona.edu
pomonamikey
wii number7808 7239 7724 0213
blackberry pin204db8e4

On Notice

  • The sun
  • Librarians
  • Blue
  • Purple
  • David Gray
  • Whirlpool
  • Taco Bell

As seen on The Colbert Report.

This site does not represent my employer.

May look horrible in Internet Explorer.

blosxom logo   Creative Commons License

gotta
knock
a
little
harder

obstrepero.us banner
obstrepero.us mistakes you can learn from

Storing cover art images in FLAC metadata blocks

filed under: /hacks/flac

Several people have looked for a way to store images, such as cover art, inside FLAC metadata blocks. (Mostly because several players such as the slimserver and the iPod can now display the album cover.) The standard FLAC distribution and its metaflac tool don't have this capability yet, so I have rolled my own:

flac-image.tar.gz (13k)
in subversion: https://svn.cs.pomona.edu/sys/src/flac-image/

The tar ball contains a binary compiled on Debian, but if that doesn't work, it is trivial to compile your own. It is also pretty trivial to use:

mikey@ember:~$ flac-image
flac-image 1.00, Copyright (c) 2005 Michael A. Dickerson

Usage:
flac-image (-x | -i <imagefile> | -d | -n | -l) [-t <mimetype>] flacfile ...

   -x: eXtract images in flacfile to current directory
   -i: Insert image <imagefile> in flacfile
   -d: Delete image blocks in flacfile
   -n: extract only the smallest available image block (thumbNail)
   -l: List recognized image blocks

   -t: with -i, use <mimetype> instead of guessing based on filename
       with any other operation, process only the blocks that match
       <mimetype>

For FLAC hackers: the APPLICATION block that I use is registered as 0x696d6167 (ASCII "imag") and has the following structure (from flac-image.h).

/* This struct is the "specification" for the flac-image APPLICATION data
   block.  The binary image data is prepended with this 72-byte header:
   
   vers - header structure version number.  The only defined value is
          0x0001.

   mimetype - 32 byte char buffer meant to describe the block content type
          (although this program could care less, and just treats the
          mimetype field as a kind of label.)

   filename - 32 byte char buffer meant to record the name of the original
          file.  Programs are free to ignore this when extracting files.
          This program stores the last component of the original filename
          when importing, and uses the same name when exporting.

   datasize - number of bytes of binary data that follow the header.
*/

typedef struct {
  unsigned int vers;
  char mimetype[IMAGE_HEADER_MIMETYPE_MAXLEN];
  char filename[IMAGE_HEADER_FILENAME_MAXLEN];
  unsigned int datasize;
} flac_image_header;

Josh has indicated that he intends to incorporate something like this in the next release of FLAC. When that happens, it should be simple to convert my image blocks to the standard scheme.

19 Jan 2005 01:47 PT - persistent link - trackback - 0 comments

Copyright © 2005-06 Michael A. Dickerson