Resizing A Image For Upload

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
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Resizing A Image For Upload

Post by icesolid »

I was wondering if it is possible to resize a image that has been sent from a form, and then upload it after it has been resized?

Right now my script just accepts the image file from a FILE input and uploads it. I want to resize the photo submitted first and THEN upload it.

Is this possible, if so how?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

nope.
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

So I would have to upload it first, and then pull it back out and resize it, and re-upload it all in one step?

Is it possible to set the size parameters of the file coming in before upload?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Who said you'd have to reupload the file again? Upload the file, resize it, move it to where you want it. Done.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

The reason I wanted to resize the photo first and then upload it is because I am uploading 20 photos at a time and they are all large images.

So if it was resized (considerably) then uploaded the load time on the submit process would be much faster.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

You can resize them in photoshop by making an action (batch process), other then that there is no other way to do it other then having some kind of java applet or activeX control that does the actual image editing on the client side. Remember PHP can't see the image until it is fully uploaded..
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

What do you mean by an action in photoshop (batch process)?

If I was to use client side code such as javascript, where would I go for reasources on learning how to resize them?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Java, not Javascript. Those are two entirely different languages.
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

I understand that they are two different languages, either way where could I get help with my solution?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Put it this way, unless you want to go through alot of trouble, you can't do it. It's not possible with PHP alone, it's a server side language. It can't handle any sort of file until it's on the server.

It would be a heck of a lot easier for you to just offer the user(s) a simple free image editting program and tell them to resize images before uploading to save time if they wish, any remotely experienced users would realise that uploading a larger file will take longer than a smaller file anyway.

If you are the only user, then as jspro2 said, Photoshops batch actions are a good idea for performing the same task on multiple files at once, such as resizing a bunch of images to the same dimensions.

If you don't care that your idea is more hassle than it's worth, as jshpro2 said (again) look into some sort of Java/Active X application to embed into your webpage, which will do the resezing client side.
Post Reply