Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!news.alphanet.ch!alphanet.ch!.POSTED!not-for-mail From: =?UTF-8?Q?Une_B=c3=a9vue?= Newsgroups: fr.comp.infosystemes.www.auteurs,fr.comp.lang.javascript Subject: =?UTF-8?Q?[Canvas]_l'image_extraite_n'a_pas_la_taille_esp=c3=a9r?= =?UTF-8?B?w6llLi4u?= Followup-To: fr.comp.infosystemes.www.auteurs Date: Mon, 13 Feb 2017 10:38:40 +0100 Organization: Posted through ALPHANET (http://www.alphanet.ch/) Lines: 39 Sender: unbewusstsein@vbo91-4-88-164-253-93.fbx.proxad.net Message-ID: NNTP-Posting-Host: vbo91-4-88-164-253-93.fbx.proxad.net Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: shakotay.alphanet.ch 1486978721 10433 88.164.253.93 (13 Feb 2017 09:38:41 GMT) X-Complaints-To: usenet@alphanet.ch NNTP-Posting-Date: Mon, 13 Feb 2017 09:38:41 +0000 (UTC) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 X-Mozilla-News-Host: news://news.alphanet.ch:119 Xref: csiph.com fr.comp.infosystemes.www.auteurs:8115 fr.comp.lang.javascript:3103 J'ai un canvas de 400x400 pixels^2 et j'en extrait un avatar de 96x96 de cette manière : handleSaveDataURL (event) { console.log(`${window.consoleDate()} - AvatarCropper :: handleSaveDataURL (event)`); let self = this; let buf = new Image(); buf.src = this.state.canvas.toDataURL(); buf.onload = function() { let canvas = document.createElement('canvas'); canvas.width = 400; canvas.height = 400; let ctx = canvas.getContext('2d'); ctx.drawImage(this, 0, 0, 400, 400, 0, 0, 96, 96); self.props.saveDataURL(canvas.toDataURL()); }; } les dataURL obtenues par "this.state.canvas.toDataURL()" sont OK elles font bien 400x400. par contre quand j'exxtrais l'avatar de 96x96 par canvas.toDataURL(), si je visualise le résultat par le biais d'un fichier html de contenu : alt="" /> Firefox Dev Ed me dit que l'image fait 400x400 pixels mais montre seulment un avatar de 96x96. Caputre écran : Aussi je ne comprends pas pourquoi firefox donne deux dimensions : 400x400 et 444.444x444.444 ???