Creating thumbnails for CSS web site.

bluestrobe

Platinum Member
Aug 15, 2004
2,033
1
0
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.
 

clamum

Lifer
Feb 13, 2003
26,252
403
126
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.
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
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.
 

esun

Platinum Member
Nov 12, 2001
2,214
0
0
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
 

bluestrobe

Platinum Member
Aug 15, 2004
2,033
1
0
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.
 

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
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.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,618
4,533
75
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