Php Resize Image Maintain Aspect Ratio. Here s code from my personal grab bag of image resizing code. Create an input form to get image and required dimension.
Resizing an image without stretching involves setting the new dimension of an image. Just calculate the aspect ratio first then multiply it with the existing height. If you want to automatically calculate the new width from a given fixed height just do the vice versa ratio new height height.
Create empty image and fill background with white color thumbnail imagecreatetruecolor width height.
Maintaining aspect ratio is also known as constraining proportions in some graphic editing software like photoshop. Create empty image and fill background with white color thumbnail imagecreatetruecolor width height. Using the same technique but image always keeps its aspect ratio. Cover image will be resized to cover the entire box while maintaining the aspect ratio.