• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Creating thumbnails for CSS web site.

bluestrobe

Platinum Member
Right now I'm using a basic HTML code to shrink images and link to the full size ones. I am looking for a simple solution to be able to post thumbnails on my main page that link to the pictures themselves. I've searched around but haven't found an easy solution without involving a decent amount of effort and time for each picture.
 
I've done the same thing you're talking about on a few different websites using PHP or ASP. Basically I send the pic to a .php or .asp file as an argument, and in there have the size coded in and send it through a built in resampling function.

It's actually quite easy. I can help you out if you would like to go either the PHP or ASP route.
 
don't use the same image with small width/height attributes, its pointless (user still downloads full image)

resizing in php is pretty easy, especially if imagemagick is installed (and it usually is)

with php
exec("/usr/bin/convert image.jpg -resize ### image.jpg);

(### is your new width)

if your images are being FTPed along with your web files, i suggest creating a photoshop droplet.
 
What I would probably do is have the PHP (or Perl, or whatever scripting language) script do a file existence check for whether the resized version (the thumbnail) exists. If not, resize the image. If so, skip it. That way, the first person to view the thumbnail will get a minor slowdown on loading the page, but from then on it should be nearly as fast as straight HTML code.

Documentation on convert is available here: http://www.imagemagick.org/scr...nd-line-processing.php
 
I load the files right at the web server or through my network. I've never heard of imagemagick so I doubt it is installed. The html resize thing was a temporary fix until I got a more viable solution.
 
By far the most efficient way to do it, both in processor time and bandwidth, is to resize all your images baforehand... if you don't want to do it manaully then you could run them through a macro in an image processing app. You could use something like imagemagick as troytime suggested - I wouldn't use it to resize on every request, but it would be good for scripting to resize everything beforehand.
 
To find out if you have imagemagick, type "convert -?" at a command prompt. If you get a large list of arguments, you have it.

If you're on Linux, I'd suggest the following command:

ls /path/images | grep "\.jpg$" | sed -e "s/\.jpg$//" | xargs -i convert -size 100x100 -thumbnail 100x100 /path/images/{}.jpg /path/images/{}_sm.jpg
 
Back
Top