Last active
January 10, 2017 13:54
-
-
Save xc2/37c1c2feb24dad549ca79fdd24f2ec3f to your computer and use it in GitHub Desktop.
Strip Image Privacy Informations
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Strip Image Privacy Informations</title> | |
</head> | |
<body> | |
<input type="file" id="hello"> | |
<div style="position: absolute; z-index: -1;"> | |
<img src="" id="world"> | |
</div> | |
<script>(function() { | |
'use strict'; | |
var f = document.getElementById('hello'); | |
var g = document.getElementById('world'); | |
f.addEventListener('change', function() { | |
load(f.files[0]) | |
}) | |
g.addEventListener('load', function() { | |
if (g.src) { | |
draw(g); | |
} | |
}) | |
function load(file) { | |
g.src = URL.createObjectURL(file); | |
} | |
function draw(img) { | |
var b = document.getElementById('b'); | |
if (b) { | |
b.parentNode.removeChild(b); | |
} | |
var c = document.createElement('canvas'); | |
c.id = 'b'; | |
c.width = img.width; | |
c.height = img.height; | |
document.body.appendChild(c); | |
var d = c.getContext('2d'); | |
d.drawImage(img, 0, 0); | |
} | |
})();</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment