tagImageDataToImageSample

Helper function for tag-reading plugins to create a #GstSample suitable to add to a #GstTagList as an image tag (such as #GST_TAG_IMAGE or #GST_TAG_PREVIEW_IMAGE) from the encoded image data and an (optional) image type.

Background: cover art and other images in tags are usually stored as a blob of binary image data, often accompanied by a MIME type or some other content type string (e.g. 'png', 'jpeg', 'jpg'). Sometimes there is also an 'image type' to indicate what kind of image this is (e.g. front cover, back cover, artist, etc.). The image data may also be an URI to the image rather than the image itself.

In GStreamer, image tags are #GstSample<!-- -->s containing the raw image data, with the sample caps describing the content type of the image (e.g. image/jpeg, image/png, text/uri-list). The sample info may contain an additional 'image-type' field of #GstTagImageType to describe the type of image (front cover, back cover etc.). #GST_TAG_PREVIEW_IMAGE tags should not carry an image type, their type is already indicated via the special tag name.

This function will do various checks and typefind the encoded image data (we can't trust the declared mime type).

Parameters

imageData ubyte[]

the (encoded) image

imageType gsttag.types.TagImageType

type of the image, or #GST_TAG_IMAGE_TYPE_UNDEFINED. Pass #GST_TAG_IMAGE_TYPE_NONE if no image type should be set at all (e.g. for preview images)

Return Value

Type: gst.sample.Sample

a newly-allocated image sample for use in tag lists, or NULL