public Sample image_data_to_image_sample (uint8[] image_data, ImageType image_type)

Helper function for tag-reading plugins to create a Sample suitable to add to a TagList as an image tag (such as IMAGE or 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 Samples 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 ImageType to describe the type of image (front cover, back cover etc.). 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).



the (encoded) image


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


the length of the encoded image data at image_data


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

Namespace: Gst.Tag