Thumbnail function?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Thumbnail function?

Post 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...
Last edited by Aaron on Wed Aug 27, 2003 3:18 pm, edited 1 time in total.
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post 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
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Post by Aaron »

Id rather have the thumbnail made instead of doing that each time...
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

you want to upload two images?

just add another form element.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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?
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Re: Thumbnail function?

Post 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...
Post Reply