Griffith Designs

Coldfusion

Determine IMG Scale Ratio

by webmasterjunkie on Aug.27, 2011, under Coldfusion, Internet, Programming, Web

Well, recently I had to vertically center an image in a square DIV. This had to be done with the image being scaled to a specific width, 90px. I know there are probably hundreds of ways to do this, but this is the one that I used to determine how much top margin to set on the image in order to center it vertically.

<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>

Continue reading “Determine IMG Scale Ratio” »

Leave a Comment :, more...

Beauty of File Naming

by webmasterjunkie on Apr.20, 2011, under Coldfusion, Designs, Internet, Programming, Service, Web

OK, there are a lot of benefits to naming the files you create when doing web design in a manner that makes sense. Recently I developed a site for a company and it was all static files with no database back-end. You can imagine that there were a lot of products and pages that had to be created as a result. When doing this I decided to go with the following convention:

category-subcategory-product-name-name.cfm

Continue reading “Beauty of File Naming” »

Leave a Comment :, , more...

Coldfusion >= PHP

by webmasterjunkie on Mar.28, 2011, under Coldfusion, PHP, Programming

Well, I have the ability to work with Coldfusion a lot lately, and am asking myself if it is worth the learning curve? There is of course a bias since any of you that are actually reading this know that I <3 PHP. There are some cool things that I have learned like there are no actual code declaration tags and built in JS form validation, but I am still waiting to see.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Connect