PDA

View Full Version : aspect ratios


Baleric
09-05-2006, 02:32 AM
hey guys,
i am trying to shrink large images in to proportion as thumbnails.
heres the problem,

i need to make a code that
devides the image width by 2 and if it still bigger then 170px then it devides it by 3 etc. then when it is smaller then 170px it devides the height by the same number

if width < 170 then
width = width /2
then if it is still bigger
width = width / 3
and so on


can someone help me with this please

thanks in advance.


cheers


baleric

degsy
09-06-2006, 03:45 PM
Where are you getting the dimensions from?

Baleric
09-07-2006, 12:04 AM
im using a script that detects the dimensions from on the server.
aswell as the date edited and ammount of colors in the photo
the script uses "w" as the width variable and "h" as the height variable.

Roelf
09-07-2006, 08:06 AM
divide the actual width by 170, round that number up to the nearest integer (like a Ceil function), divide width and height by that integer

Baleric
09-07-2006, 01:26 PM
no idead what you mean.... can you explain it a little more indepth please

Roelf
09-07-2006, 01:50 PM
say the image is 350 px wide, divide by 170 gives 2,05. Round up to 3, then divide the original width by 3: gives 117 (rounded) px. Then divide the height of the original image also by 3 to conserve aspect ratio. This way the result is always below 170px

Baleric
09-10-2006, 12:05 PM
all done :)

<%
dim width
width = w/350

dim width2
width2 = round(width)

%>


thanks for the help reolf