Add Comment
Creating Square Thumbnails Tutorial
ColdFusion Tutorial #26
I recently worked on a project that allowed users to upload images and I then needed to create different versions of the image... a 1200 x N, 430 x N, and 75x75... wait it has to be square!? Yeah that was my first thought, nah that won't work
What about stretching it?
Nope that looks like junk
What about white bars ALA Your DVD player?
Image is too small and they want the image to fill up the whole square.
Hmm how about a nice sized-down-then-chopped image?
yeah that would look cool.
So how do we do it?
demo.cfm
We want to create the thumbnail and do all kinds of math to figure out how to crop.That is where the "FromX" and "FromY" variables comes in.
It figures out where the upper left hand corner is then it walks its way to the middle of the image less half the height of the desired image.
From the it crops the image to the desired size.
Demo
See this code running!
Download
Download this code as a zip!
Comments
There are no comments!Click button to add a comment
Author
J.J. Merrick
Published
Wednesday 23 Jan 2008Original
This tutorial has been modified and published with permission of the author. The original tutorial can be found herehttp://jeremiahx.com/2007/12/04/creating-nice-square-thumbnails-with-cfimage/