---
title: "Creating Thumbnails for Video"
canonical: https://www.graphicsmill.com/docs/gm5/CreatingVideoPreviews.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# Creating Thumbnails for Video
 
One of the typical tasks where Media Processor Add-on can be useful is creating video thumbnails. For example, if you want to create a collection of your video files, for each of them you can store a small preview image along with other descriptive data. Later these screenshots can be displayed while you browse the collection.
 
The function that will create thumbnails should perform the following operations:
 
1. Create a reader and open the source file.
2. Find a non-empty frame in the source file. The simplest way to do it is to read a frame from the middle of the video file using the [IFormatReader.LoadFrame(Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_IFormatReader_LoadFrame_1_e1836fc4.htm.md) method.
3. Create an empty instance of the [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md) object.
4. Initialize the Bitmap object with the resized frame in one of the ways:
    - Call the [GetThumbnail(Bitmap, Int32, Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_Frame_GetThumbnail_3_90f33463.htm.md) method to get a resized version of the frame.
    - Call the [GetBitmap(Bitmap)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_Frame_GetBitmap_1_fd4033ef.htm.md) method to get the frame as it is. Then, if additional transformations are required, modify the Bitmap object.
5. Save the bitmap, for example, with the help of the [Save](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Bitmap_Save.htm.md) method.
6. Close the reader.

The following code snippets show how this can be done.
 
```
Public Sub CreateVideoThumbnail(ByVal inputFilename As String, ByVal _
    outputBaseFilename As String)
    Try
        'Create the reader
        Dim reader As IFormatReader = MediaFormatManager.CreateFormatReader _
             (inputFilename)
        'Get the frame
        If reader.FrameCount < 1 Then
            Console.WriteLine("File contains no frames.")
            Return
        End If
        Dim index As Int32 = reader.FrameCount / 2
        Dim frame As IFrame = reader.LoadFrame(index)
        'Save the frame using GetThumbnail()
        Dim image1 As Aurigma.GraphicsMill.Bitmap = New _
            Aurigma.GraphicsMill.Bitmap
        frame.GetThumbnail(image1, 160, 120)
        image1.Save(outputBaseFilename + "1.gif")
        image1.Dispose()
        'Save the frame using GetBitmap() and Resize
        Dim image2 As Aurigma.GraphicsMill.Bitmap = New _
            Aurigma.GraphicsMill.Bitmap
        frame.GetBitmap(image2)
        Dim transformation As Resize = New Resize(160, 120)
        transformation.ApplyTransform(image2)
        image2.Save(outputBaseFilename + "2.gif")
        image2.Dispose()
        reader.Dispose()
    Catch ex As Exception
        Console.WriteLine(ex)
    End Try
End Sub
```
 
```csharp
public static void CreateVideoThumbnail(string inputFilename,
    string outputBaseFilename)
{
    try
    {
        //Create the reader
        IFormatReader reader = MediaFormatManager.CreateFormatReader(inputFilename);
        //Get the frame
        if (reader.FrameCount < 1)
        {
            Console.WriteLine("File contains no frames.");
            return;
        }
        Int32 index = reader.FrameCount / 2;
        IFrame frame = reader.LoadFrame(index);
        //Save the frame using GetThumbnail()
        Aurigma.GraphicsMill.Bitmap image1 = new Aurigma.GraphicsMill.Bitmap();
        frame.GetThumbnail(image1, 160, 120);
        image1.Save(outputBaseFilename + @"1.gif");
        image1.Dispose();
        //Save the frame using GetBitmap() and Resize
        Aurigma.GraphicsMill.Bitmap image2 = new Aurigma.GraphicsMill.Bitmap();
        frame.GetBitmap(image2);
        Resize transformation = new Resize(160, 120);
        transformation.ApplyTransform(image2);
        image2.Save(outputBaseFilename + @"2.gif");
        image2.Dispose();
        reader.Dispose();
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex);
    }
}
```
 
## See Also
  
### Samples
 
- [Splitting Video Files to JPEGs](https://www.graphicsmill.com/docs/gm5/SplittingVideoToJpegs.htm.md)

### Reference
 
- [Aurigma.GraphicsMill.Bitmap Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md)
- [Frame.GetBitmap(Bitmap) Method](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_Frame_GetBitmap_1_fd4033ef.htm.md)
- [Frame.GetThumbnail(Bitmap, Int32, Int32) Method](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_Frame_GetThumbnail_3_90f33463.htm.md)

### Manual
 
- [Reading Video Files Frame by Frame](https://www.graphicsmill.com/docs/gm5/ReadingVideoFrameByFrame.htm.md)
