By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,281 Members | 2,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,281 IT Pros & Developers. It's quick & easy.

resize image on client side

P: n/a
Hi all,

I've a classic upload form where people may select images on their computer
to send on my website.

Since this is done by people not very confortable with computers, some sent
pictures are very huge (3MB) and I do resize them anyway since I only allow
500px wide pictures.

Instead of letting people upload the 3MB file then resize it on the server,
isn't there any possibility to "reduce" the file resolution on the client's
machine then upload on the server the reduced picture using javascript or
any other method ?

Thanks for any tip
May 4 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
rf
"Bob Bedford" <bo*@bedford.comwrote in message
news:46**********************@news.sunrise.ch...
Hi all,

I've a classic upload form where people may select images on their
computer to send on my website.

Since this is done by people not very confortable with computers, some
sent pictures are very huge (3MB) and I do resize them anyway since I only
allow 500px wide pictures.

Instead of letting people upload the 3MB file then resize it on the
server, isn't there any possibility to "reduce" the file resolution on the
client's machine then upload on the server the reduced picture using
javascript or any other method ?
No.

--
Richard.
May 4 '07 #2

P: n/a
On May 4, 12:57 pm, "Bob Bedford" <b...@bedford.comwrote:
Hi all,

I've a classic upload form where people may select images on their computer
to send on my website.

Since this is done by people not very confortable with computers, some sent
pictures are very huge (3MB) and I do resize them anyway since I only allow
500px wide pictures.

Instead of letting people upload the 3MB file then resize it on the server,
isn't there any possibility to "reduce" the file resolution on the client's
machine then upload on the server the reduced picture using javascript or
any other method ?

Thanks for any tip
the only ways would be to write a firefox extension, use activex for
IE (not recommended) or write an auto-upload script which doesnt use a
browser and uses something like imagemagick to crunch the images.
You could offer a .NET download to people which could resize nicely,
and then offer the upload from within the GUI which showed the ETA, it
would allow batch jobbing for more fun.
If this isnt worth it, just tell them what programs are out there
which resize and some instructions and then let them know approx times
for uploads if they don't resize first, and you could also provide the
user with some feedbck about the eta, either live, or after the
initial upload has begun you could use the filesize and approx
connection speed (you got earlier using some javascript) and show them
their eta, offering a link to the instructions page.

May 4 '07 #3

P: n/a
Bob Bedford wrote:
Hi all,

I've a classic upload form where people may select images on their computer
to send on my website.

Since this is done by people not very confortable with computers, some sent
pictures are very huge (3MB) and I do resize them anyway since I only allow
500px wide pictures.

Instead of letting people upload the 3MB file then resize it on the server,
isn't there any possibility to "reduce" the file resolution on the client's
machine then upload on the server the reduced picture using javascript or
any other method ?
I am going to venture an answer and say, "no."

JavaScript (without privileges) cannot write to the file system
(security and all).

Also bear in mind, size of the image is not the same thing as its width
and height.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 4 '07 #4

P: n/a
-Lost said the following on 5/4/2007 8:49 AM:
Bob Bedford wrote:
>Hi all,

I've a classic upload form where people may select images on their
computer to send on my website.

Since this is done by people not very confortable with computers, some
sent pictures are very huge (3MB) and I do resize them anyway since I
only allow 500px wide pictures.

Instead of letting people upload the 3MB file then resize it on the
server, isn't there any possibility to "reduce" the file resolution on
the client's machine then upload on the server the reduced picture
using javascript or any other method ?

I am going to venture an answer and say, "no."
Your venture is a successful one :)
JavaScript (without privileges) cannot write to the file system
(security and all).
It would need to do more than that. It would need to execute a program
on the users PC to be able to manipulate images as Javascript itself has
no means at all to modify image data.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 4 '07 #5

P: n/a
On May 4, 3:02 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
-Lost said the following on 5/4/2007 8:49 AM:
Bob Bedford wrote:
Hi all,
I've a classic upload form where people may select images on their
computer to send on my website.
Since this is done by people not very confortable with computers, some
sent pictures are very huge (3MB) and I do resize them anyway since I
only allow 500px wide pictures.
Instead of letting people upload the 3MB file then resize it on the
server, isn't there any possibility to "reduce" the file resolution on
the client's machine then upload on the server the reduced picture
using javascript or any other method ?
I am going to venture an answer and say, "no."

Your venture is a successful one :)
JavaScript (without privileges) cannot write to the file system
(security and all).

It would need to do more than that. It would need to execute a program
on the users PC to be able to manipulate images as Javascript itself has
no means at all to modify image data.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

There are ways this can be done as mentioned above by shimmyshack. At
the moment, probably the best way to do it is with a Java applet (for
example: http://www.radinks.com/upload/ ). If you want to write your
own, have a look at the apache commons libraries in particular
fileupload, httpclient and net.

Another possibility (and i am not sure if this would work), is the
Google Gears javascript project. This gives you access to a local
datbase which you have write access to. Assuming you can access a file
from the file input object in html, you could resize an image with
your javascript (assuming you can do this), and store it in the local
database, then upload the resized image to your server. This is all
theoretical, and i have no idea if it would work, or if it is
possible...but its an idea...

Jun 18 '07 #6

P: n/a
to*********@gmail.com wrote:
On May 4, 3:02 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>-Lost said the following on 5/4/2007 8:49 AM:
>>Bob Bedford wrote:
Hi all,
I've a classic upload form where people may select images on their
computer to send on my website.
Since this is done by people not very confortable with computers, some
sent pictures are very huge (3MB) and I do resize them anyway since I
only allow 500px wide pictures.
Instead of letting people upload the 3MB file then resize it on the
server, isn't there any possibility to "reduce" the file resolution on
the client's machine then upload on the server the reduced picture
using javascript or any other method ?
I am going to venture an answer and say, "no."
Your venture is a successful one :)
>>JavaScript (without privileges) cannot write to the file system
(security and all).
It would need to do more than that. It would need to execute a program
on the users PC to be able to manipulate images as Javascript itself has
no means at all to modify image data.

There are ways this can be done as mentioned above by shimmyshack. At
the moment, probably the best way to do it is with a Java applet (for
example: http://www.radinks.com/upload/ ). If you want to write your
own, have a look at the apache commons libraries in particular
fileupload, httpclient and net.
But the simple and end-all answer is "no." It cannot be done with
JavaScript alone.
Another possibility (and i am not sure if this would work), is the
Google Gears javascript project. This gives you access to a local
datbase which you have write access to. Assuming you can access a file
from the file input object in html, you could resize an image with
your javascript (assuming you can do this), and store it in the local
database, then upload the resized image to your server. This is all
theoretical, and i have no idea if it would work, or if it is
possible...but its an idea...
Sure, it is possible with XHRs and server-side. I am sure no one would
argue that. Again though, can it be done with JavaScript only? No.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 18 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.