Skip to content

Commit f96a87e

Browse files
committed
better image display in the canvas
1 parent 4a1cc47 commit f96a87e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tools/NFT_Marker_Creator/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h2 class="title has-text-centered" id="title" href="#confidenceLevel">NFT Marke
1313
<button class="button is-fullwidth" id="generateBt" onclick="window.generate()" disabled>Generate</button>
1414
</div>
1515
<div class="tile is-ancestor" id="wrapper">
16-
<canvas class="tile" id="imageCanvas" style="width: auto; height: 120rem"></canvas>
16+
<canvas class="tile" id="imageCanvas" ></canvas>
1717
<div class="spinner-container">
1818
<div class="spinner"></div>
1919
</div>

tools/NFT_Marker_Creator/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,14 @@ function useJpeg(e) {
208208
function readImage(e) {
209209
reader.onload = function (event) {
210210

211-
var img = new Image();
211+
const img = new Image();
212212
img.onload = function () {
213-
var canvasEl = document.querySelector('#imageCanvas');
214-
canvas.width = canvasEl.clientWidth;
215-
canvas.height = canvasEl.clientHeight;
213+
canvas.width = img.width;
214+
canvas.height = img.height;
215+
216+
canvas.style.width = img.width > 1200 ? '1200px' : img.width + 'px';
217+
canvas.style.height = img.height > 1200 ? '1200px' : img.height + 'px';
218+
216219

217220
hideCanvas.width = img.width;
218221
hideCanvas.height = img.height;

0 commit comments

Comments
 (0)