ImageThumbNail

ImageThumbNail — resizes images by pixels.

Syntax

ImageThumbNail (image, wgoal, hgoal)

		

Arguments

image

An 8-bit image, instance of the PhImage class, such as returned by a call to PxLoadImage.

wgoal

The desired width of the thumbnail, in pixels.

hgoal

The desired height of the thumbnail, in pixels.

Returns

An image on success, otherwise nil.

Description

This function reduces or enlarges an image to the height and width specified. Although both height and width must be specified, ImageThumbNail always reduces or enlarges proportionally, using the smaller of two size parameters.

To use this function, you must load the ImageProc.lsp library with a call to require_lisp("ImageProc.lsp").

Example

This example, ex_ImageThumbNail.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
This example puts up a window with a label image.  (Size: 96 by 96
pixels). Next to this image is the same image reduced by 1/4 and 3/4.
In the second reduction, arguments were passed for a dispropotional
result, but ImageThumbNail() chooses the smaller of the two.
*/

PtInit(nil);
require_lisp("PhotonWidgets.lsp");
require_lisp("ImageProc.lsp");

win = new(PtWindow);
win.SetDim(250,200);

img = PxLoadImage("smiley.bmp");
lab = ImageToLabel(img);
lab.SetPos(25,25);

imgt1 = (ImageThumbNail(img,24,24));
labelt1 = ImageToLabel(imgt1);
labelt1.SetPos(150,25);

imgt2 = (ImageThumbNail(img,72,200));
labelt2 = ImageToLabel(imgt2);
labelt2.SetPos(150,80);

PtRealizeWidget(win);
PtMainLoop();

See Also

PxReduceImage