learn

JPG Image Scale

category: Snippets
Created by: Assaad Youssef Abou-Rached

JPG Image Scale

category: Snippets
Created by: Assaad Youssef Abou-Rached
twitter google+ facebook pinned 

JPG Image Scale

One of the most important things in websites is to have your images look good and not distorted.
Our function will scale the image based on a ration between image height and width.
Say you want to scale all of your images to maximum width of 300px and maximum height of 100px. You upload an image of size 700x400px.
The function will resize the image to 100px in height and calculate the value of width proportionally to height. So the final result will be 175x100px

works with JPG images only
Considering you have an image named image.jpg in the same directory as this script and you have a folder named uploads