Skip to content

Instantly share code, notes, and snippets.

@RedRussianBear
Created November 27, 2018 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedRussianBear/9be3a48fe91260be987dbd783e85192e to your computer and use it in GitHub Desktop.
Save RedRussianBear/9be3a48fe91260be987dbd783e85192e to your computer and use it in GitHub Desktop.
// Image upload handler
$('#upload').change(function () {
const file = this.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
$('body').css('background-image', 'url("' + reader.result + '")');
$('#colors').html('<h2>Processing...</h2>');
getColors(reader.result.substr(reader.result.search('base64,') + 7));
};
reader.onerror = function (error) {
console.error('Error: ', error);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment