Answered
cfscript. recalculating numbers
Hello
I have a database with images. There are 3 columns, one with the width, the other one with the height and the last one the name of the file.
I would like now to send width and height to a cfscript which recalculates the width/height values - I know this sounds strange but I need it for a representation on a website. So note that I don't want to resize the oiginal image, I just want to have values. I neither want to change anything in the database!
And I don't need to do that on several images at the time!
I imagine something like this: <cfset newDimension = rescaleImage(503,2004,250,500)>
where
'rescaleImage' would be the script
503 the width coming from my database
2004 the height coming from my database
250 the max. width
500 the max. height
So the script should check.
1. whether the dimension has to be resized (if smaller than the max. values the output should be the values similar to the ones in the database)
2. whether the width has to be reduced to the max. width and the height calculated proportionally to the max. width
3. whether the height has to be reduced to the max. height and the width calculated proportionally to the max. height
and the output could be a two value list containing width and height....
Does anybody know whether such a script already exists or can somebody help me wrting it (what means this somebody would have to write it ;-)
Many thanks
Actually I could calculate this stuff in Coldfusion with cfif and evaluate and so, but I think this is so much code each time. So i prefer sending values to a script and get the stuff back....
I have a database with images. There are 3 columns, one with the width, the other one with the height and the last one the name of the file.
I would like now to send width and height to a cfscript which recalculates the width/height values - I know this sounds strange but I need it for a representation on a website. So note that I don't want to resize the oiginal image, I just want to have values. I neither want to change anything in the database!
And I don't need to do that on several images at the time!
I imagine something like this: <cfset newDimension = rescaleImage(503,2004,250,500)>
where
'rescaleImage' would be the script
503 the width coming from my database
2004 the height coming from my database
250 the max. width
500 the max. height
So the script should check.
1. whether the dimension has to be resized (if smaller than the max. values the output should be the values similar to the ones in the database)
2. whether the width has to be reduced to the max. width and the height calculated proportionally to the max. width
3. whether the height has to be reduced to the max. height and the width calculated proportionally to the max. height
and the output could be a two value list containing width and height....
Does anybody know whether such a script already exists or can somebody help me wrting it (what means this somebody would have to write it ;-)
Many thanks
Actually I could calculate this stuff in Coldfusion with cfif and evaluate and so, but I think this is so much code each time. So i prefer sending values to a script and get the stuff back....
