I\'m creating a web service for an iPhone app to interact with.
When my client uploads images server-side, I want my php script to resize the image, whilst m
Maybe a slightly shorter routine would be:
// Calculate resize ratios for resizing
float ratioW = targetWidth / oldWidth;
float ratioH = targetHeight / oldHeight;
// smaller ratio will ensure that the image fits in the view
float ratio = ratioW < ratioH?ratioW:ratioH;
newWidth = oldWidth*ratio;
newHeight = oldHeight*ratio;
Obviously if the ratio is > 1, then it's enlarging, if < 1 then it's shrinking.