From: Peter H. <ph...@ma...> - 2007-01-29 22:12:14
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, Jan 29, 2007 at 12:38:15PM -0600, Melanie McClusky wrote: > I create a custom "photo gallery" . Currently my client upload a thumbnail > and the regular size image. Now my client only wants to upload a regular > size image and have the "system" automaticly create a thumbnail. Other folks have given very good suggestions to produce resized photos, but I wanted to chime in to mention there's a quick-and-dirty hack: set the height and width attributes of the image to scale the iamge down. They won't load any faster than full size and it'll be tempting to put a lot of them on a page, making for a very slow page. But it's handy in a pinch. Here's a function to resize images -- you pass in the current width and height and a new maximum width and maximum height, and it'll return an array with the a new width and height that preserve the image's aspect ratio. function get_scaled_dimensions($width, $height, $max_width, $max_height) { if (width > height) $scale = $max_width / $width; else $scale = $max_height / $height; return array(floor($width * $scale), floor($height * $scale)); } - -- Peter Harkins - http://push.cx - http://nearbygamers.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: If you don't know what this is, it's OK to ignore it. iD8DBQFFvnE3a6PWv6+ALKoRAsrnAJ9NT8XhAmSOaVUcH4dvK7gePaNzaQCfUfBx T7ycYi00I2mR9znceRYi/5g= =GFIm -----END PGP SIGNATURE----- |