Skip to content

Instantly share code, notes, and snippets.

@ana-balica
Created May 23, 2013 04:48
Show Gist options
  • Save ana-balica/5632803 to your computer and use it in GitHub Desktop.
Save ana-balica/5632803 to your computer and use it in GitHub Desktop.
Pictalicious - a Chrome Extension for determining the best colors to use with an image via Pictaculous (http://www.pictaculous.com/).
{
"manifest_version": 2,
"name": "Pictalicious",
"description": "Get the perfect pallete right from this webpage picture. Pictaculous knows what colors to use with an image.",
"version": "1.0",
"permissions": [
"<all_urls>"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
<!doctype html>
<html>
<head>
<title>Picture Pictaculous</title>
<style type="text/css">
body{min-width:400px; min-height:300px; overflow-x:hidden;}
</style>
<script src="jquery-1.9.1.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<button type="button">Click here!</button>
</body>
</html>
$(document).ready(function() {
$("button").click(function(e) {
c('button clicked');
file = "http://www.vectorstock.com/i/composite/56,72/sleeping-kitten-vector-95672.jpg";
file_reader = new FileReader();
var data = file_reader.readAsArrayBuffer(file);
c(data);
// $.ajax({
// type: "POST",
// url: "http://pictaculous.com/api/1.0/",
// data: {"image": "http://www.vectorstock.com/i/composite/56,72/sleeping-kitten-vector-95672.jpg"},
// contentType: "image/jpeg",
// processData: false
// }).success(function(data) {
// c(data);
// });
});
});
function download_image(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
if (this.status == 200) {
var blob = new Blob([this.response], {type: 'image/png'});
}
};
xhr.send();
}
function c(val) {
console.log(val);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment