WMAs/ASF tags work differently to other formats when adding a picture

Issue #289 new
Dan Gravell created an issue

Up to now I’ve just been setting an image as so:

Artwork someArtwork = ...
tag.addField(someArtwork);

In ASF tags, the getBinaryData() on someArtwork is passed to the AsfTagCoverField.

A bunch of other metadata is then mixed in with the image data in createRawContentand a byte array is created. The AsfTagCoverField then updates its MetadataDescriptor with this byte array

Subsequently, when getArtworkList is called on the same ASF tag later, the resulting Artwork instances contain the metadata as part of the bytes in getBinaryData. Other formats only return the image data. I think the API contract is therefore broken.

The reason the metadata is included is because the endOfName variable in AsfTagCoverField is not correctly set after the AsfTagCoverField is created. getRawImageData() is correctly called to return the image bytes, but the result contains the metadata because endOfName is not set and so the metadata is not skipped.

In an alternative constructor, processRawContent is called which does set endOfName. This constructor is called when reading the file. As a result getArtworkList works fine for freshly-loaded files.

So the workaround is to, after adding some artwork, reload the file.

I think `processRawContent` should be called when a new artwork field is added, although I haven’t run the tests to ensure this doesn’t have any side effects.

Comments (1)

  1. Log in to comment