From bd6d760d36fe8e9f841976743360f8cca95f000c Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 26 Feb 2009 01:27:07 +0100 Subject: [PATCH] Added support for loading and saving cover art in WMA --- picard/formats/asf.py | 53 +++++++++++++++++++++++++++++++++++++++++-- picard/formats/id3.py | 2 +- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/picard/formats/asf.py b/picard/formats/asf.py index c628f941d..0569c37b5 100644 --- a/picard/formats/asf.py +++ b/picard/formats/asf.py @@ -20,7 +20,45 @@ from picard.file import File from picard.util import encode_filename from picard.metadata import Metadata -from mutagen.asf import ASF +from mutagen.asf import ASF, ASFByteArrayAttribute +import struct + +def unpack_image(data): + """ + Helper function to unpack image data from a WM/Picture tag. + + The data has the following format: + 1 byte: Picture type (0-20), see ID3 APIC frame specification at http://www.id3.org/id3v2.4.0-frames + 4 bytes: Picture data length in LE format + MIME type, null terminated UTF-16-LE string + Description, null terminated UTF-16-LE string + The image data in the given length + """ + (type, size) = struct.unpack_from("