function JPEGResample(imgFile, maxWidth, maxHeight, quality)

The JPEGResample function resizes a JPEG image (imgFile) 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 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.


 JPEGResample('./self_portrait.jpg', 800, 600, 90);