Skip to content

Instantly share code, notes, and snippets.

@xc2
Last active January 10, 2017 13:54
Show Gist options
  • Save xc2/37c1c2feb24dad549ca79fdd24f2ec3f to your computer and use it in GitHub Desktop.
Save xc2/37c1c2feb24dad549ca79fdd24f2ec3f to your computer and use it in GitHub Desktop.
Strip Image Privacy Informations
<!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