is a reliable and extendable PHP method that can be embedded as a library into web applications > do first resize, then crop image to fix width and height without losing dimension ratio in a user-friendly and simple way. Horizontal or landscape format, cut always either from right side or from bottom to get final width and height without stretching. Save original width and generated thumbnail in a web comfort jpg format.Show more information...
The desired storage location, final height, final width, quality, and the image file in .jpg, .gif, or .png format can be included as a parameter in the method.
The following steps are executed by the function on the basis of the transferred parameters:
- Check of minimum size, check of image format, and security checks.
- The original image is moved/saved to the specified storage location.
- The image is scaled to the specified final height or width (so that the final height or width is not exceeded and there is no loss in dimension).
- The image is cropped either from the right or from the bottom.
- The transparent background is filled white.
- Finally the thumbnail is saved in a web comfort jpg format by this function, and the storage location of the thumbnail is returned as a parameter for further processing (return value).
This method should work and run on a wide range of php servers and works without additional pear php extensions!
It is so easy to get it running ;)