Table of Contents

VideoThumbnailer.GenerateThumbnail Method

Definition

Namespace
GleamTech.VideoUltimate
Assembly
GleamTech.VideoUltimate.dll

GenerateThumbnail(int, int, bool, int)

Generates a meaningful thumbnail for the video by seeking to a sensible time position and avoiding blank frames. Every call returns a new GleamTech.Drawing.Image instance which should be disposed by the caller. Once the smart time position is determined after the first call, the consecutive calls will be faster and can be used to retrieve GleamTech.Drawing.Image instances in different sizes.

public Image GenerateThumbnail(int width, int height, bool overlayDuration = false, int fontSize = 0)

Parameters

width int

The width of the thumbnail. If value is 0, width will be automatically calculated to preserve aspect ratio.

height int

The height of the thumbnail. If value is 0, height will be automatically calculated to preserve aspect ratio.

overlayDuration bool

Whether to overlay the duration of the video on the bottom-right corner.

fontSize int

The font size to be used for duration overlay. If value is 0, font size will be automatically calculated according to height.

Returns

Image

A new GleamTech.Drawing.Image instance.

Examples

caller

A GleamTech.Drawing.Image parameter/property can be explicitly cast from/to other image libraries:

Below are the examples for casting a GleamTech.Drawing.Image parameter/property from/to other image libraries.

Casting from/to System.Drawing.Bitmap and System.Drawing.Image:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var systemBitmap = new System.Drawing.Bitmap("Test.bmp");
var systemImage = System.Drawing.Image.FromFile("Test.jpg");

//Casting from System.Drawing.Bitmap:
gleamTechImage = systemBitmap.ToGleamTechImage();

//Casting to System.Drawing.Bitmap:
systemBitmap = gleamTechImage.ToSystemBitmap();

//---------------------------------------

//Casting from System.Drawing.Image:
gleamTechImage = systemImage.ToGleamTechImage();

//Casting to System.Drawing.Image:
systemImage = gleamTechImage.ToSystemImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim systemBitmap As New System.Drawing.Bitmap("Test.bmp")
Dim systemImage As Object = System.Drawing.Image.FromFile("Test.jpg")

'Casting from System.Drawing.Bitmap:
gleamTechImage = systemBitmap.ToGleamTechImage()

'Casting to System.Drawing.Bitmap:
systemBitmap = gleamTechImage.ToSystemBitmap()

'---------------------------------------

'Casting from System.Drawing.Image:
gleamTechImage = systemImage.ToGleamTechImage()

'Casting to System.Drawing.Image:
systemImage = gleamTechImage.ToSystemImage()

Casting from/to SixLabors.ImageSharp.Image:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var imageSharpImage = SixLabors.ImageSharp.Image.Load("Test.jpg");

//Casting from SixLabors.ImageSharp.Image:
gleamTechImage = imageSharpImage.ToGleamTechImage();

//Casting to SixLabors.ImageSharp.Image:
imageSharpImage = gleamTechImage.ToImageSharpImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim imageSharpImage As Object = SixLabors.ImageSharp.Image.Load("Test.jpg")

'Casting from SixLabors.ImageSharp.Image:
gleamTechImage = imageSharpImage.ToGleamTechImage()

'Casting to SixLabors.ImageSharp.Image:
imageSharpImage = gleamTechImage.ToImageSharpImage()

Casting from/to SkiaSharp.SKBitmap and SkiaSharp.SKImage:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var skiaBitmap = SkiaSharp.SKBitmap.Decode("Test.bmp");
var skiaImage = SkiaSharp.SKImage.FromBitmap(skiaBitmap);

//Casting from SkiaSharp.SKBitmap:
gleamTechImage = skiaBitmap.ToGleamTechImage();

//Casting to SkiaSharp.SKBitmap:
skiaBitmap = gleamTechImage.ToSkiaBitmap();

//---------------------------------------

//Casting from SkiaSharp.SKImage:
gleamTechImage = skiaImage.ToGleamTechImage();

//Casting to SkiaSharp.SKImage:
skiaImage = gleamTechImage.ToSkiaImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim skiaBitmap As Object = SkiaSharp.SKBitmap.Decode("Test.bmp")
Dim skiaImage As Object = SkiaSharp.SKImage.FromBitmap(skiaBitmap)

'Casting from SkiaSharp.SKBitmap:
gleamTechImage = skiaBitmap.ToGleamTechImage()

'Casting to SkiaSharp.SKBitmap:
skiaBitmap = gleamTechImage.ToSkiaBitmap()

'---------------------------------------

'Casting from SkiaSharp.SKImage:
gleamTechImage = skiaImage.ToGleamTechImage()

'Casting to SkiaSharp.SKImage:
skiaImage = gleamTechImage.ToSkiaImage()

Casting from/to Microsoft.Maui.Graphics.Platform.PlatformImage:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var mauiImage = new Microsoft.Maui.Graphics.Platform.PlatformImage(imageBytes);

//Casting from Microsoft.Maui.Graphics.Platform.PlatformImage:
gleamTechImage = mauiImage.ToGleamTechImage();

//Casting to Microsoft.Maui.Graphics.Platform.PlatformImage:
mauiImage = gleamTechImage.ToMauiImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim mauiImage As New Microsoft.Maui.Graphics.Platform.PlatformImage(imageBytes)

'Casting from Microsoft.Maui.Graphics.Platform.PlatformImage:
gleamTechImage = mauiImage.ToGleamTechImage()

'Casting to Microsoft.Maui.Graphics.Platform.PlatformImage:
mauiImage = gleamTechImage.ToMauiImage()

GenerateThumbnail(int, bool, int)

Generates a meaningful thumbnail for the video by seeking to a sensible time position and avoiding blank frames. Every call returns a new GleamTech.Drawing.Image instance which should be disposed by the caller. Once the smart time position is determined after the first call, the consecutive calls will be faster and can be used to retrieve GleamTech.Drawing.Image instances in different sizes.

public Image GenerateThumbnail(int maxSize, bool overlayDuration = false, int fontSize = 0)

Parameters

maxSize int

The maximum width or height of the thumbnail, aspect ratio is preserved. If width is bigger than height, than the value would be maximum width else it would be maximum height. If value is 0, original width and height will be used.

overlayDuration bool

Whether to overlay the duration of the video on the bottom-right corner.

fontSize int

The font size to be used for duration overlay. If value is 0, font size will be automatically calculated according to height.

Returns

Image

A new GleamTech.Drawing.Image instance.

Examples

caller

A GleamTech.Drawing.Image parameter/property can be explicitly cast from/to other image libraries:

Below are the examples for casting a GleamTech.Drawing.Image parameter/property from/to other image libraries.

Casting from/to System.Drawing.Bitmap and System.Drawing.Image:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var systemBitmap = new System.Drawing.Bitmap("Test.bmp");
var systemImage = System.Drawing.Image.FromFile("Test.jpg");

//Casting from System.Drawing.Bitmap:
gleamTechImage = systemBitmap.ToGleamTechImage();

//Casting to System.Drawing.Bitmap:
systemBitmap = gleamTechImage.ToSystemBitmap();

//---------------------------------------

//Casting from System.Drawing.Image:
gleamTechImage = systemImage.ToGleamTechImage();

//Casting to System.Drawing.Image:
systemImage = gleamTechImage.ToSystemImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim systemBitmap As New System.Drawing.Bitmap("Test.bmp")
Dim systemImage As Object = System.Drawing.Image.FromFile("Test.jpg")

'Casting from System.Drawing.Bitmap:
gleamTechImage = systemBitmap.ToGleamTechImage()

'Casting to System.Drawing.Bitmap:
systemBitmap = gleamTechImage.ToSystemBitmap()

'---------------------------------------

'Casting from System.Drawing.Image:
gleamTechImage = systemImage.ToGleamTechImage()

'Casting to System.Drawing.Image:
systemImage = gleamTechImage.ToSystemImage()

Casting from/to SixLabors.ImageSharp.Image:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var imageSharpImage = SixLabors.ImageSharp.Image.Load("Test.jpg");

//Casting from SixLabors.ImageSharp.Image:
gleamTechImage = imageSharpImage.ToGleamTechImage();

//Casting to SixLabors.ImageSharp.Image:
imageSharpImage = gleamTechImage.ToImageSharpImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim imageSharpImage As Object = SixLabors.ImageSharp.Image.Load("Test.jpg")

'Casting from SixLabors.ImageSharp.Image:
gleamTechImage = imageSharpImage.ToGleamTechImage()

'Casting to SixLabors.ImageSharp.Image:
imageSharpImage = gleamTechImage.ToImageSharpImage()

Casting from/to SkiaSharp.SKBitmap and SkiaSharp.SKImage:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var skiaBitmap = SkiaSharp.SKBitmap.Decode("Test.bmp");
var skiaImage = SkiaSharp.SKImage.FromBitmap(skiaBitmap);

//Casting from SkiaSharp.SKBitmap:
gleamTechImage = skiaBitmap.ToGleamTechImage();

//Casting to SkiaSharp.SKBitmap:
skiaBitmap = gleamTechImage.ToSkiaBitmap();

//---------------------------------------

//Casting from SkiaSharp.SKImage:
gleamTechImage = skiaImage.ToGleamTechImage();

//Casting to SkiaSharp.SKImage:
skiaImage = gleamTechImage.ToSkiaImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim skiaBitmap As Object = SkiaSharp.SKBitmap.Decode("Test.bmp")
Dim skiaImage As Object = SkiaSharp.SKImage.FromBitmap(skiaBitmap)

'Casting from SkiaSharp.SKBitmap:
gleamTechImage = skiaBitmap.ToGleamTechImage()

'Casting to SkiaSharp.SKBitmap:
skiaBitmap = gleamTechImage.ToSkiaBitmap()

'---------------------------------------

'Casting from SkiaSharp.SKImage:
gleamTechImage = skiaImage.ToGleamTechImage()

'Casting to SkiaSharp.SKImage:
skiaImage = gleamTechImage.ToSkiaImage()

Casting from/to Microsoft.Maui.Graphics.Platform.PlatformImage:

var gleamTechImage = new GleamTech.Drawing.Image("Test.png");
var mauiImage = new Microsoft.Maui.Graphics.Platform.PlatformImage(imageBytes);

//Casting from Microsoft.Maui.Graphics.Platform.PlatformImage:
gleamTechImage = mauiImage.ToGleamTechImage();

//Casting to Microsoft.Maui.Graphics.Platform.PlatformImage:
mauiImage = gleamTechImage.ToMauiImage();
Dim gleamTechImage As New GleamTech.Drawing.Image("Test.png")
Dim mauiImage As New Microsoft.Maui.Graphics.Platform.PlatformImage(imageBytes)

'Casting from Microsoft.Maui.Graphics.Platform.PlatformImage:
gleamTechImage = mauiImage.ToGleamTechImage()

'Casting to Microsoft.Maui.Graphics.Platform.PlatformImage:
mauiImage = gleamTechImage.ToMauiImage()