Quote:
|
Originally Posted by ryan_f
Im working on a website right now and i made a script in php to upload an image and then display it on a different page. It works very well. My only problem is that i want to be able to turn those images into thumbnails with small file sizes automatically once i upload the file to my server. I don't really know that much php and i have no idea how i would accomplish this
|
Could you just use something like Gallery?
If not, I've done some work on that, you can check this link:
http://users.wpi.edu/~woloi/pictures.txt
I haven't looked at that since early summer, so I can't say I know what I did, but if you can't figure out what I did, I'd be more than happy to look back at it and help you. I believe the only problem should be mess and such, cause I never actually cleaned that code up.
Specifically, look at the following code, though it will need to be modified for your purposes:
Code:
function Thumbnails ($pics, $root, $thumbnails) {
#Pre: $pics is filled
#Post: Thumbnails are created for every new picture in directory
if ( !is_dir($thumbnails)) {
mkdir ($thumbnails);
chmod ($thumbnails, 0755);
}
else if (is_dir ($thumbnails)) {
for ($i = 0; $i < count($pics); $i++) {
if (!is_file($thumbnails . '/' . $pics[$i])) {
exec ("convert $root/$pics[$i] -resize 150x150 +profile '*' $thumbnails/$pics[$i]");
chmod ("$thumbnails/$pics[$i]", 0755);
}
}
Hope that helps.