Click to See Complete Forum and Search --> : basic PHP thumbnail creation script. (read...)
mysticalice
09-06-2004, 01:29 PM
hi.
i frequently upload pictures to folders online, but they're usually fairly large (500KB+ quite often)... i need a basic script that will make thumbnails of the images, and then display them (create an index.php or something, so that when people go to my folder, instead of showing the directory listing with 30 pictures, it shows the thumbnails of the pictures) and when you click the thumbnail it loads the regular size picture.
anyone? please let me know.
Thanks a lot
~Lorenzo
Eupseudes
09-06-2004, 02:01 PM
That would not be a php script. You're manipulating images, and that takes a lot of processing power. I would suggest you use a batch image converter like Irfanview to mass convert all your files to thumbnails. Then it's a simple matter of using a php script to dynamically generate the link and thumbnail paths.
mysticalice
09-06-2004, 05:04 PM
hmmm OK. so you're saying i shouldn't make the server do it, i should convert them myself, then upload the thumbnails and the full-size pictures to the server...
i'm completely new to PHP, so what PHP script can i use that will look at all the thumbnails in the folder, and display them all (and link, for instance, thumbnail100 to picture100 when i click the thumbnail).
Da Warriah
09-06-2004, 09:18 PM
If all your thumbnails and pictures have a specific name like you mentioned (thumbnail100 and picture100), you could just use a loop to display each picture, such as:
<?php
for($i = 0; $i <=50; $i++){
?>
<a href="picture<?php echo $i; ?>.jpg"><img src="thumbnail<?php echo $i; ?>.jpg" /></a>
<?php
}
?>
On the other hand, if the names of the images could be anything (like pictureofbob.jpb), then you might want to look into opendir() (http://ca3.php.net/manual/en/function.opendir.php) and its other related functions.
mysticalice
09-07-2004, 12:19 AM
OK i'll try that and let you know if it works :)
Thanks
mysticalice
09-07-2004, 12:22 AM
hey
i was just looking at the script (havn't had time to try it yet, it's late) but my images are labeled: thumbnail0001 - thumbnail0156 and bigpicture001 to bigpicture156
how would i get it to do that, because isn't the variable saved as "5" instead of "005"?
NogDog
09-07-2004, 09:21 AM
Use sprintf() (http://us2.php.net/manual/en/function.sprintf.php):
$name = "test";
$number = 5;
$name_number = sprintf("%s%03d", $name, $number);
echo "$name_number";
cybercampbell
09-08-2004, 03:57 AM
Hi mate
Keep an eye on this tread, it may intrest you.
http://www.webdeveloper.com/forum/showthread.php?s=&threadid=42539
Cheers
Chris
mysticalice
09-08-2004, 11:53 PM
ok thanks. i'll do that.
i'm very, very, very new to PHP. in fact i'm new to programming as a whole. i took Java in school for a year, so i'm familiar with the C-style i guess, but don't have much (if any) experience in it.
i know this may be a bit off topic, but one of you guys may know: I'm trying to get into Linux. i'm going to install Debian right away, although it's extremely hard, but i'd rather have a lot of problems with the hardest linux source than struggle through a bunch of them making my way up. to install and run debian, i'm going to piece together a computer from some parts i have lying around... what would you say are the bare necessities i'd need for the hardware to run Debian? just an experimental computer, not going to be running a big file server or anything. maybe in the future i'll run a small game server just for me and my friends. but what would you recommend?