grass valley developers

Home > APIs > AppServer API > Examples > Asset Management > Get Asset Thumbnail Image

Get Asset Thumbnail Image

Below is sample code showing how to get a thumbnail image for an asset and then save it in different formats.

[C#]
// get a media manager object
using (IMediaMgr mediaMgr = iappServer.CreateMediaMgr(appName) )
{
	// get thumbnail byte array for the asset V:/default/Clip
	System.Byte[] imageBytes = (System.Byte[]) mediaMgr.GetThumbnail(
		"edl/cmf//local/V:/default/Clip");

	// create a memory stream from the bytes
	using ( MemoryStream ms = new MemoryStream(imageBytes) )
	{
		// create bitmap from memory stream
		using ( Bitmap bitmap = new Bitmap(ms) )
		{
			// save bitmap in various formats
			bitmap.Save("bitmap.jpg", ImageFormat.Jpeg);
			bitmap.Save("bitmap.gif", ImageFormat.Gif);
			bitmap.Save("bitmap.png", ImageFormat.Png);
			bitmap.Save("bitmap.bmp", ImageFormat.Bmp);
		}
	}
}