While I'd normally advocate msw's solution, that site doesn't seem to have a lib for Flash. However, it DOES have the ID3v2 specification. If you look at section 4., ID3v2 frame overview
, you'll see the frame header includes the frame's size, not including the header. I believe it's safe to assume the image size can be calculated from there.
PD: I'm assuming you know how ID3v2 tags work. In case you don't, I recommend you give at least a cursory glance at the spec. Basically, there's a header, an extended header, then one or more frames containing the tag's data (one frame per datum) and finally padding.
EDIT: For testing purposes I opened one of my MP3s with known tag data in my hex editor. Found a frame named APIC
, copied the specified number of bytes into a new file and saved it as test.jpg
. Didn't quite work.
Digging further, I found the frame spec. Specifically, Section 4.14, attached picture
, which describes a "subheader" of sorts for the frame (1-byte text encoding, zero-delimited mimetype, 1-byte picture type and a zero-delimited description). So I trimmed that information out of the data and copied the remainder onto a new jpg, which Windows was able to show.
Therefore, the technique is:
- Acquire frame size from frame header.
- Parse out the beginning of the frame for the frame subheader and remove it. (Anywhere between 4 and infinite bytes)
- Calculate image size based on remaining number of bytes.