Skip to content

Instantly share code, notes, and snippets.

@kchapelier
Last active April 28, 2017 12:15
Show Gist options
  • Save kchapelier/8708a907f6782caece9b6b768c5ef14c to your computer and use it in GitHub Desktop.
Save kchapelier/8708a907f6782caece9b6b768c5ef14c to your computer and use it in GitHub Desktop.
UnEXIF: UnProtect Your Work!
/***
Undoing the hacks of https://www.exif.co/ with unsophisticated javascript.
As an artist, the best way to protect your work is to approach sharing technologies and third party services with a healthy dose of scepticism and to always clearly specify the license under which your work is made available on the Internet.
***/
// click on an image served by exif.co to replace it with a canvas containing the full image
document.body.addEventListener('click', function (e) {
if(e.target.parentNode && e.target.parentNode.classList.contains('js-exif-image')) {
var element = e.target.parentNode,
firstImage = element.querySelector('img:nth-of-type(1)'),
secondImage = element.querySelector('img:nth-of-type(2)'),
imageWidth = firstImage.naturalWidth,
imageHeight = firstImage.naturalHeight,
canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');
canvas.width = imageWidth;
canvas.height = imageHeight;
canvas.style = 'max-width:100%;max-height:100%;width:auto;height:auto;display:block;';
element.parentNode.parentNode.insertBefore(canvas, element.parentNode);
element.parentNode.style.display='none';
ctx.drawImage(firstImage, 0, 0 );
ctx.drawImage(secondImage, imageWidth / 100 * parseFloat(secondImage.style.marginLeft), imageHeight / 100 * parseFloat(secondImage.style.top) );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment