Last active
August 29, 2015 14:17
-
-
Save krisselden/273e2ffbfc13246428ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'http://localhost:3333/www.fnordware.com/superpng/pnggrad8rgb.jpg', true); | |
xhr.responseType = 'blob'; | |
xhr.onload = function(e) { | |
var reader = new FileReader(); | |
reader.onloadend = function() { | |
var img = document.createElement('img'); | |
img.onload = function () { | |
var canvas = document.createElement("canvas"); | |
canvas.width = img.width; | |
canvas.height = img.height; | |
document.body.appendChild(canvas); | |
var ctx=canvas.getContext("2d"); | |
ctx.drawImage(img,0,0); | |
var imageData = ctx.getImageData(0,0,img.width,img.height); | |
canvas = document.createElement("canvas"); | |
canvas.width = img.width; | |
canvas.height = img.height; | |
document.body.appendChild(canvas); | |
ctx=canvas.getContext("2d"); | |
for (var i=0;i<imageData.data.length;i+=4) | |
{ | |
imageData.data[i] = 255-imageData.data[i]; // RED | |
imageData.data[i+1] = 255-imageData.data[i+1]; // GREEN | |
imageData.data[i+2] = 255-imageData.data[i+2]; // BLUE | |
imageData.data[i+3] = 255; // ALPHA | |
} | |
ctx.putImageData(imageData,0,0); | |
console.log(imageData); | |
} | |
img.src = this.result; | |
} | |
reader.readAsDataURL(this.response); | |
}; | |
xhr.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daemon off; | |
master_process off; | |
error_log /dev/stdout notice; | |
events { } | |
http { | |
access_log off; | |
server { | |
listen 3333; | |
server_name _; | |
resolver 8.8.8.8; | |
location ~ "^/(.*)/(.*)" { | |
proxy_pass http://$1/$2; | |
proxy_buffering off; | |
proxy_redirect off; | |
proxy_ignore_headers Set-Cookie; | |
proxy_set_header Authorization ''; | |
proxy_set_header Origin ''; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
add_header Access-Control-Allow-Origin "*"; | |
add_header Access-Control-Allow-Methods "GET"; | |
add_header Access-Control-Max-Age "1728000"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
start with nginx -c /absolute/path/to/nginx.conf