Skip to content

Instantly share code, notes, and snippets.

@JKirchartz
Created October 14, 2018 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JKirchartz/0af002c96546922ce5eee710b62d4ecc to your computer and use it in GitHub Desktop.
Save JKirchartz/0af002c96546922ce5eee710b62d4ecc to your computer and use it in GitHub Desktop.
Javascript to manipulate image in @jkirchartz_exe
var text = document.getElementById('text');
text.setAttribute('textLength', Math.round(text.clientWidth / 1.1));
text.style.fontSize = Math.round(text.clientWidth / text.textContent.length) + 'px';
var img=document.getElementById('image');
img.onload=function(){
var svg=document.getElementById('svg');
svg.height=img.naturalHeight;
svg.width=img.naturalWidth;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment