Page 1 of 2

Reduce base64 image using Javascript

Posted: Sat Dec 21, 2013 11:06 pm
by Bahar Wadia

Is there anyway to reduce the size (both in pixels and KB) of a base64 image that I capture using a camera. I am trying to reduce the size of the image before loading it to the database.


Reduce base64 image using Javascript

Posted: Sun Dec 22, 2013 12:03 am
by maxkatz

There might be a way to do it.. you should search for a possible solution/library to do that.


Reduce base64 image using Javascript

Posted: Tue Dec 24, 2013 12:47 am
by bahar.wadia

I have been looking, but I have not been very successful.

I cannot be the only one on the planet facing this problem.

In my app I allow the user to take a bunch of pictures, which they can upload to the database. All this works fine.

Also in my app, I allow the user to view Thumbnails of the actual pictures, which they can select if they wish to see the picture in full size. As you can imagine, downloading all the pictures in their full size to show as thumbnails is a very slow and wasteful process.

I would ideally like to reduce the image size (in bytes) on the server side and return the reduced image to the client.

Any suggestions or brilliant ideas?

Thanks so much in advance.


Reduce base64 image using Javascript

Posted: Tue Dec 24, 2013 8:15 am
by Kateryna Grynko

Reduce base64 image using Javascript

Posted: Tue Dec 24, 2013 4:48 pm
by bahar.wadia

Can I use canvas on the server side script, without actually having a document on the server ? OR is there some other way ?


Reduce base64 image using Javascript

Posted: Tue Dec 24, 2013 9:50 pm
by Maryna Brodina

Hello! [quote:]Can I use canvas on the server side script, without actually having a document on the server ?[/quote] no, there is no way to use Canvas in ServerCode. To create thumbnail for PNG pictures you can use https://github.com/niegowski/node-pngjs library. This library is to read/save PNG files. But decreasing picture size algorithm should be coded by you.


Reduce base64 image using Javascript

Posted: Wed Dec 25, 2013 9:34 pm
by bahar.wadia

So how can this be done on the client side before uploading the image to the server ?


Reduce base64 image using Javascript

Posted: Wed Dec 25, 2013 9:41 pm
by Maryna Brodina

Reduce base64 image using Javascript

Posted: Thu Dec 26, 2013 4:35 am
by bahar.wadia

That works nicely.

Thank you!


Reduce base64 image using Javascript

Posted: Fri Sep 25, 2015 6:07 am
by buyi wen

you can try this free online service to convert image to base64 string online.