Jump to content

algorithm for uploading images so they all have exact same width and height?


zander1983

Recommended Posts

Hi

Im working on a market place style website. the framework im using is called elgg. it uses an algoritm to find the right approximate width and height of an image thats being uploaded. but on my site, all heights and widths must be the same. this is difficult because some pictures have much greater width than height and some have much greater height. so whats the best algoritm to use to make an accurate thumbnail of all images uploaded?

Thanks

//have a static width and find the percentage of that in terms of the original width, then times it by the original height
$width = $imageWidth;
$height = $imageHeight;

$newWidth = 300;

$newHeight = $newWidth / $width * $height;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.