Thread: File resize?
View Single Post
  #6   Spotlight this post!  
Unread 10-10-2004, 01:12
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
Re: File resize?

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.
__________________
AIM --> Woloi
Email --> ian@woloschin.com