cf_image_shrink

image_shrink is a custom tag I hacked together today. Its purpose is to take an image and shrink it down to a size that fits within predefined limits on width and height and maintain the image’s aspect ratio.

This works on at least CF6 (that’s why there are no null JavaCasts, which would have shortened the code a bit).

I figured, like the CFHTTP stuff, I’d share this with anyone who might find it useful. It’s not production quality stuff, it needs a bit of work here and there, but it gets the job done.

It’s boggling the number of different ways there are to accomplish the same task. I created no less than 4 different versions of this trying to find the one that produced the best results and allowed for the most control.

It only outputs JPEGs and if you input transparent PNGs you’ll get a black background by default (thus the cffile tag only allows for jpeg images to be accepted, but you can change that of course).

As for what I’m working on right now in terms of design it’s a redesign of the entire site I manage for work. The design itself came from a separate office and I’m working to put it into the sort of tableless, compatible forms I’ve put out in the past.

It’s proving to be a bit of a challenge, but I think I’ve got it. I’m starting to develop a taste for a certain style where you use 2-pixel-wide borders around key elements and the color of the border should be close to the background color of the element it’s wrapped around. I like the subtlety of the effect. It will also include a more correct form of access-bar where you can change the size of the font (and eventually the page style). This uses form buttons rather than images, which cuts down on files that users have to transfer and it’s a tad more accessible.

I’ve also had to string three boxes with different backgrounds next to each other and include a gap between them. Each box needs to be of equal width and height. This presents quite a challenge. During my work I found that Opera calculates percentages differently than every other browser out there. As a result I had to define the widths of these boxes in a slightly round-about manner to get Opera on board. I get nervous getting into decimal-percents, but so far my testing shows the big browsers are all working fine.

If all goes well there will be a demo website up in September that I can show everyone. I don’t think I can really release the layout as a ZIP for people to use on their own sites. I may put together a new layout that uses some of these key features I’ve had to develop, but one that doesn’t share the style or feel of the layout I’m developing now.

So that’s what’s going on.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s