JPEGResample (resize a JPG)
function JPEGResample(
imgFile: string,
maxWidth: number,
maxHeight: number,
quality: number
): boolean;
The JPEGResample
function resizes the imgFile
JPEG image/picture using the Lanczos3 resampling method to keep the best possible level of detail.
This function also retains the original image’s aspect-ratio, and chooses between maxWidth
and maxHeight
(both in pixels) whichever one would result in a smaller image. If you wish one of these two parameters to be ignored, simply set it to 0 (zero).
The last parameter quality
is a numeric value, between 1 and 100, that indicates the desired quality of the resulting image inversely proportional to its lossy compression; basically an image saved with quality index of 25 will produce a smaller file but lose a lot more detail than an image saved with quality index of 75.
This function returns true if the image was resized successfully, or false if errors occurred.
Example
{
JPEGResample('./self_portrait.jpg', 800, 600, 90);
}