Skip to content

Instantly share code, notes, and snippets.

View anchal20's full-sized avatar
🏃‍♀️
Back to coding days!!!!

Anchal Sachdeva anchal20

🏃‍♀️
Back to coding days!!!!
View GitHub Profile
@shellophobia
shellophobia / UploadFilesCompress.md
Last active April 15, 2018 17:18
Upload Images with compression on front end

Upload Images with Compression on Front-End

Its a plugin that enables you upload image files to the server with a front-end side compression using javascript. So basically the image that you upload gets redrawn on the canvas with new dimension that you specify in the options and a compressed base64 encoded string is obtained from it. Now most of us these days have a phone with a fancy camera, that clicks the images of sizes of around 8-13 MB. So uploading that kind of size onto the server is totally not acceptable. So you wish to either compress on front end side or the server side. Android has some libraries that allows you to compress the files before sending onto the server, but on the other hand there is no such solid lead available on the browser side.

So here's a plugin that comes to the rescue.

The logic behind compression is that the larger size images have ample amount of resolution to them, but most of the time that kind of resolution is not needed. So this plugin is basically resizing the high

@ecarter
ecarter / mapOrder.js
Created December 2, 2011 15:40
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];