GdPicture image identifier. The image from which the thumbnail must be done.
The width of the thumbnail to create.
The height of the thumbnail to create.
Example





In This Topic
GdPicture14 Namespace / GdPictureImaging Class / CreateThumbnail Method

CreateThumbnail Method (GdPictureImaging)

In This Topic
Creates thumbnail of custom size from a GdPicture image.
Syntax
'Declaration
 
Public Function CreateThumbnail( _
   ByVal ImageID As Integer, _
   ByVal Width As Integer, _
   ByVal Height As Integer _
) As Integer
public int CreateThumbnail( 
   int ImageID,
   int Width,
   int Height
)
public function CreateThumbnail( 
    ImageID: Integer;
    Width: Integer;
    Height: Integer
): Integer; 
public function CreateThumbnail( 
   ImageID : int,
   Width : int,
   Height : int
) : int;
public: int CreateThumbnail( 
   int ImageID,
   int Width,
   int Height
) 
public:
int CreateThumbnail( 
   int ImageID,
   int Width,
   int Height
) 

Parameters

ImageID
GdPicture image identifier. The image from which the thumbnail must be done.
Width
The width of the thumbnail to create.
Height
The height of the thumbnail to create.

Return Value

GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Remarks
If both of Width and Height parameters are 0, a system-defined size is used.

This method requires the Image Documents component to run.

Example
Working with thumbnails.
Generating a custom size thumbnail from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
 
    // Create a thumbnail that is 100 pixels width and 200 pixels height.
    int thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 100, 200);
    gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
 
    // Release used resources.
    gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removing the existing thumbnail and creating and attaching a new one to a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
 
    int thumbnailID = 0;
    if (gdpictureImaging.HasAttachedThumbnail(imageID))
    {
        // Get the already attached thumbnail and save it as an image, then detach it.
        thumbnailID = gdpictureImaging.GetAttachedThumbnail(imageID);
        gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
        gdpictureImaging.DetachThumbnail(imageID);
        gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
    }
 
    // Create a new thumbnail with a system-defined size and attach it to an image.
    thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 0, 0);
    gdpictureImaging.AttachThumbnail(imageID, thumbnailID);
 
    // Release used resources.
    gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also