Gabriel Posted October 1, 2021 at 11:23 PM Report Share #623998 Posted October 1, 2021 at 11:23 PM Boas, tenho o seguinte código abaixo que cria um filtro para uma foto. let canvas = document.getElementById('canvas'); let c = canvas.getContext('2d'); let filename = "profile-photo"; let btnDownload = document.getElementById('download'); let reader = new FileReader(); let target = new Image(); let target2 = new Image(); let image = document.getElementById('image_perfil'); let image2 = document.getElementById('image_logo') c.canvas.width = 1024; c.canvas.height = 1024; let download = function () { link = document.createElement('a'); link.download = filename + '.png'; link.href = document.getElementById('canvas').toDataURL() link.click(); } let destroyInterval = () => { for (var i = 1; i < 99999; i++) window.clearInterval(i); } let load = () => { c.clearRect(0, 0, c.canvas.width, c.canvas.height); draw(); } let draw = () => { // made reponsive twibbon c.canvas.width = target.width; c.canvas.height = target.height; c.drawImage(target, 0, 0, target.width, target.height); c.drawImage(target2, 0, 0, target.width, target.height); } let enableButton = () => { let } let init = () => { run = setInterval(function () { load(); }, 1000); } //IMAGEM SELECIONADA DA PASTA let setTwibbon = () => { target2.src = 'images/IXER.png'; } let imageReaderOnLoad = () => { reader.onload = (res) => { target.src = res.target.result.replace(/ +/g, ""); } } let enableBtnDownload = () => { btnDownload.removeAttribute('disabled'); } let generate = () => { if (image.files[0] === undefined) alert('Nenhuma imagem selecionada'); else { destroyInterval(); imageReaderOnLoad(); setTwibbon(); enableBtnDownload(); // reader.readAsDataURL(image.files[0]); reader.readAsDataURL(image.files[0]); init(); } } Só que só consigo o resultado que quero se na função setTwibbon é passado uma imagem dentro de uma pasta do projeto. Como fazer para que a imagem seja de forma upload? Clicar num input type file e essa imagem selecionada tomar o lugar do target2? Link to comment Share on other sites More sharing options...
M6 Posted October 2, 2021 at 02:18 PM Report Share #624000 Posted October 2, 2021 at 02:18 PM Fazes upload via Ajax para a pasta do projeto. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now