Page 1 of 1

Thumbnail function?

Posted: Tue Aug 26, 2003 12:57 pm
by Aaron
I have a form that submits a file, checks it, and then uploads it.

I would like a small function that would also upload a thumbnail, only the file should be submited to the function, the variables for the thumb should be in the actual function and not its header.

Code: Select all

$explode = explode(".", $profimg_name);
	$extension = $explode[1];


	$uid = "".$user_properties['uid']."";
	copy($profimg, "images/wuggyuploads/pictures/$uid.$extension");
	unlink($profimg);
	
	$success = "Changes applied to your account.";
	$forward = "index.php";
	success_box($success, $forward);
So basically, from what Ive read and sligtly understand, just under copy Id do something like create the thumb and copy that to the same directory with a diffrent name 'tmb_' somewhere possibly...

Posted: Tue Aug 26, 2003 2:43 pm
by pootergeist
if you have a GD build above 2 (and preferably not 2.0.10-2.0.14) you could use this thumbnail class

upload the big image, then just include the class and call a transformation (basic resize would be)

include('thumbnil_create.php');
$variable = new Thumbnail(##pointer##,200,150,'output_image.jpg',85);
$variable->create();

replacing ##pointer## with either $_FILES['fieldref']['tmp_name'] or the pointer of where you moved the big file to. amend 200,150 to suit your desired max_width, max_height. determine an output filename and set a compression

Posted: Tue Aug 26, 2003 3:27 pm
by Aaron
Id rather have the thumbnail made instead of doing that each time...

Posted: Tue Aug 26, 2003 4:41 pm
by pootergeist
you want to upload two images?

just add another form element.

Posted: Tue Aug 26, 2003 4:47 pm
by Unipus
I think he wants to automate the upload of a second image. I assume this is based on a common naming system? So, if I upload '/images/duck.jpg' the script is supposed to also automatically find '/images/thumbs/duck_tn.jpg' and upload that too? Is that the idea?

Re: Thumbnail function?

Posted: Wed Aug 27, 2003 3:18 pm
by Aaron
Aaron wrote:I have a form that submits a file, checks it, and then uploads it.

I would like a small function that would also upload a thumbnail, only the file should be submited to the function, the variables for the thumb should be in the actual function and not its header.

Code: Select all

$explode = explode(".", $profimg_name);
	$extension = $explode[1];


	$uid = "".$user_properties['uid']."";
	copy($profimg, "images/wuggyuploads/pictures/$uid.$extension");
	unlink($profimg);
	
	$success = "Changes applied to your account.";
	$forward = "index.php";
	success_box($success, $forward);
So basically, from what Ive read and sligtly understand, just under copy Id do something like create the thumb and copy that to the same directory with a diffrent name 'tmb_' somewhere possibly...