Just in Case:
I found code that allows a user to write custom text on an image on front end on a previous stack question stackoverflow.com/questions/175643...
I would just like to replace the button "choose file" upload button with a dropdown selector where users can only select images from my library and a button to download the image with the custom text on. Please help. Herewith the code:
<!doctype html><html><head><metacharset="utf-8"><title></title><script>varmaxSize=600,// Max width or height of the imagefont='italic small-caps bold 40px/50px arial',// font stylefontColor='white',// font colortextX=50,// text x positiontextY=50,// text y positionh=function(e){varfr=newFileReader();fr.onload=function(e){varimg=newImage();img.onload=function(){varr=maxSize/Math.max(this.width,this.height),w=Math.round(this.width*r),h=Math.round(this.height*r),c=document.createElement("canvas"),cc=c.getContext("2d");c.width=w;c.height=h;cc.drawImage(this,0,0,w,h);cc.font=font;cc.fillStyle=fontColor;cc.fillText(document.getElementById('t').value,textX,textY);this.src=c.toDataURL();document.body.appendChild(this);}img.src=e.target.result;}fr.readAsDataURL(e.target.files[0]);}window.onload=function(){document.getElementById('f').addEventListener('change',h,false);}</script></head><body>
1.write text
<inputtype="text"id="t">
2.add image
<inputtype="file"id="f"></body></html>
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (1)
Just in Case:
I found code that allows a user to write custom text on an image on front end on a previous stack question stackoverflow.com/questions/175643...
I would just like to replace the button "choose file" upload button with a dropdown selector where users can only select images from my library and a button to download the image with the custom text on. Please help. Herewith the code: