2

When uploading a lot of images to a server, to minimize the space taken by the images, is it better to resize the images before sending to the server or upon receiving them?

It seems to me that resizing them in JavaScript can take long time for not a lot of gains. Is there any value to doing it on the client side?

EDIT:

The backend is JAVA and the server will have multiple users at onces possibly loading images and other files to it.

2

From a speed point of view, your Computer is most likely much faster than the server you have for your website/web-application, so it would make more sense to resize on the client, than on the server.

I have a Java application where I change certain color pixels to another color, and then size the image down, and that total operation takes about 0.005 seconds per image to convert.


HOWEVER:

You are asking about Javascript as the client, and resizing there. I am not sure how fast Javascript can resize an image, or how easy it is to do it, so it might be faster to do it on the server (from your Java tag I'm assuming you are using a Java Backend)?


HOWEVER...:

Depending on what your app does, it might be too much work to do on the server( in the case of many users taxing the server resources).


I would say that if you want to keep the load off of the server, and your server doesn't have much power, I would do it on the client.

If you have a server that can handle a large load (if you need it), and has enough power to do many conversions, then do it on the server.


Overall, the answer comes down to trying it out for yourself, test your environment, and see what works best for you.

You might find that you can upload a million images, from 10 thousand different users concurrently, and your server laughs at it....

Or you find that you to upload 100 images, by yourself, and your server starts to cry.

Do you need it for many users? Just yourself? You didn't provide enough information to say, so once you do, I will update my answer...

Hope this helps.


Additional info.

Most likely when you send the image to the server for resizing, you will have to

  1. first save the image, read the image on the server,

  2. resize,

    then either

  3. overwrite,

    or

  4. delete the old

  5. save the new.

    This could possibly take some time, unless you could send the data as a stream, and read that on your server, but not sure about that capability in Javascript.

if it's all done on the client, then you only will be saving the image once.

  • So there isn't any specific 'value' to do it on the client side other than reducing the load from the server. The server (JAVA back end) can handle lots of request and there will be multiple users upload images here and there. I guess to make a better user experience it would be preferable to do it server side as I think most of the users have slow pc. – Alex May 15 '16 at 1:37
  • I don't think there is any value in doing it client side, if the clients will be slow, and the servers are much faster. You should be able to do it much faster in Java, than doing it in Javascript, so I would say Server-Side would be a lot better. The thing is you will have to, most likely, save the images, read them, alter them, then resave them (overwriting the old one, or deleting and creating a new one), so there are a few additional steps on the server, than just saving it straight. – XaolingBao May 15 '16 at 1:42
3

If disc space is the only constraint then it doesn't matter which end resizes the image. The client might do it slightly slower than the server or the server may be overloaded with clients sending many images so its a judgement call for you to make based on expected usage patterns.

However, there is one good reason for resizing on the client: network transmission. If you're uploading a multi-megabyte camera image that is going to be resize to a thumbnail (to take extremes for example) then resizing on the client is going to be faster and more efficient - the time taken to transfer the large image is likely to be much greater than that required to resize and transfer the few Kb resulting from the resized image even if the resizing operation itself might be faster on the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.