ImageGear .NET v24.12 - Updated
Resize Method (ImGearProcessing)
Example 




ImageGear24.Core Assembly > ImageGear.Processing Namespace > ImGearProcessing Class : Resize Method
Image to resize.
New image width.
New image height.
Interpolation options.
Resizes an image according to the specified dimensions.
Syntax
'Declaration
 
Public Shared Sub Resize( _
   ByVal page As ImGearPage, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal options As ImGearInterpolationOptions _
) 
'Usage
 
Dim page As ImGearPage
Dim width As Integer
Dim height As Integer
Dim options As ImGearInterpolationOptions
 
ImGearProcessing.Resize(page, width, height, options)
public static void Resize( 
   ImGearPage page,
   int width,
   int height,
   ImGearInterpolationOptions options
)
public: static void Resize( 
   ImGearPage* page,
   int width,
   int height,
   ImGearInterpolationOptions* options
) 
public:
static void Resize( 
   ImGearPage^ page,
   int width,
   int height,
   ImGearInterpolationOptions^ options
) 

Parameters

page
Image to resize.
width
New image width.
height
New image height.
options
Interpolation options.
Remarks
This method processes all channels of the image as well as the image's ROI, if it exists.

Interpolation options are ignored when resizing vector images.

Applicability of interpolation options to raster images depend on the color space and bit depth of the image. The following table specifies applicability of interpolation options to different types of raster images.

ImGearInterpolations Bitonal images Non-bitonal images
NONE Yes Yes
AVERAGE Only if both new width and height are not smaller than original width and height. Yes, except indexed images where palette is not grayscale or inverted grayscale.
BILINEAR Only if both new width and height are not smaller than original width and height. Yes, except indexed images where palette is not grayscale or inverted grayscale.
NEAREST_NEIGHBOR Yes Yes
GRAYSCALE Only if both new width and height are not greater than original width and height. No
PRESERVE_WHITE Only if both new width and height are not greater than original width and height. No
PRESERVE_BLACK Only if both new width and height are not greater than original width and height. No
BICUBIC No Yes, except indexed images where palette is not grayscale or inverted grayscale.

ImGearProcessingVerifier.CanApplyResize method can be called to check whether the operation can be performed.

This method is not supported for vector PDF pages.

Example
// Resizes an image to 128 pixels wide maintaining aspect ratio using bicubic resizing.
int newHeight = 128 * igRasterPage.DIB.Height / igRasterPage.DIB.Width;
ImGearBicubicInterpolationOptions igBicubicInterpolationOptions = new ImGearBicubicInterpolationOptions();
igBicubicInterpolationOptions.Sharpness = 1.5;
ImGearProcessing.Resize(igRasterPage, 128, newHeight, igBicubicInterpolationOptions);
' Resizes an image to 128 pixels wide maintaining aspect ratio using bicubic resizing.
Dim newHeight As Integer = 128 * igRasterPage.DIB.Height / igRasterPage.DIB.Width
Dim igBicubicInterpolationOptions As New ImGearBicubicInterpolationOptions()
igBicubicInterpolationOptions.Sharpness = 1.5
ImGearProcessing.Resize(igRasterPage, 128, newHeight, igBicubicInterpolationOptions)
See Also

Reference

ImGearProcessing Class
ImGearProcessing Members
ImGearPage Class