Thumbnail Making Script

Want to just shoot the breeze? Forum 42 is the place!

Moderator: Moderators

Post Reply
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Thumbnail Making Script

Post by gannon »

I made my own thumbnail making script :)
Because of the limits of php I only have it working with jpeg, gif, and png files.
http://www.gannon.tk/thumbs.phps
nos_slived
Higher Idiot
Posts: 3476
Joined: Mon Mar 21, 2005 6:32 pm
Location: Burnaby, BC, Canada
Contact:

Post by nos_slived »

I'd like to see that in action :D .
Image
Nightmare
Posts: 273
Joined: Sat Mar 05, 2005 8:15 am

Post by Nightmare »

I like it but 3 different functions and they are all the same except the filetype right?

Why not use a variable to hold the filetype like.

function thumbs($image_name)
{
global $dir;
global $new_width;
$size = getimagesize ("$dir/$image_name");
$new_height=$size[1]*($new_width/$size[0]);
$destimg=ImageCreate($new_width,$new_height) or die("Problem Creating image");
$srcimg=ImageCreateFrom$IMAGETYPE("$dir/".$image_name) or die("Problem opening Source Image");
ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,$size[0],$size[1]) or die("Problem resizing");
Image$IMAGETYPE($destimg,"$dir/thumbs/".$image_name) or die("Problem saving");
}

if ($type=="jpeg" OR $type=="jpg" OR $type=="JPEG" OR $type=="JPG")
{
$IMAGETYPE = JPEG
thumbs ($files[$p]);
}

:D worth a try..
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

yeah, I could :P
I actually forgot a part that ,although not a necessity, does clean up the image a bit. I should use
$destimg=ImageCreateTRUECOLOR($new_width,$new_height) or die("Problem Creating image");
instead of
$destimg=ImageCreate($new_width,$new_height) or die("Problem Creating image");
for JPEGS and PNGS. Just another variable addition I suppose though. Anyways, I'm too lazy at the moment to refine the script. I have it working so that's all that matters :)
Nightmare
Posts: 273
Joined: Sat Mar 05, 2005 8:15 am

Post by Nightmare »

yeah! :D

Nice script though.
Post Reply