Determine IMG Scale Ratio
by webmasterjunkie on Aug.27, 2011, under Coldfusion, Internet, Programming, Web
<cfobject type="JAVA" action="Create" name="tk" class="java.awt.Toolkit"></cfobject> <cfobject type="JAVA" action="Create" name="img" class="java.awt.Image"></cfobject> <!--- requires knowing the desired width of the image/div ---> <cfset imgDims = 90 /> <cfscript> imagePath = ExpandPath ("/uploads/Image/sponsors/#sm_image#"); img = tk.getDefaultToolkit().getImage("#imagePath#"); imgWidth = img.getWidth(); imgHeight = img.getHeight(); percentage = (imgDims / imgWidth) * 100; newHeight = round((imgHeight * percentage) / 100); margin = (imgDims - newHeight) / 2; </cfscript>
Now this makes the task easy using the built in capabilities of JAVA in ColdFusion! Once that was done, I simply outputted the margin variable in the inline css of the page. I tried a few “dynamic” CSS options, but none of them seemed to do the trick for me.
Link to this post!

Connect
Enter your WordPress.com blog URL
http://.wordpress.com
Proceed