From 96b64957109ba82aff1c7bccea46c4ef713a1763 Mon Sep 17 00:00:00 2001 From: Josh birnholz Date: Mon, 3 Apr 2023 20:08:50 -0400 Subject: [PATCH] Add JPEG download option --- creator/index.html | 1 + js/creator-23.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/creator/index.html b/creator/index.html index 00cc0ac5..06916e2c 100644 --- a/creator/index.html +++ b/creator/index.html @@ -671,6 +671,7 @@

Download your card

+
Click here to download as JPEG
Click here for an alternative download
diff --git a/js/creator-23.js b/js/creator-23.js index 972f1ab6..6dcb178e 100644 --- a/js/creator-23.js +++ b/js/creator-23.js @@ -3404,13 +3404,20 @@ function drawCard() { previewContext.drawImage(cardCanvas, 0, 0, previewCanvas.width, previewCanvas.height); } //DOWNLOADING -function downloadCard(alt = false) { +function downloadCard(alt = false, jpeg = false) { if (card.infoArtist.replace(/ /g, '') == '' && !card.artSource.includes('/img/blank.png') && !card.artZoom == 0) { notify('You must credit an artist before downloading!', 5); } else { // Prep file information - const imageDataURL = cardCanvas.toDataURL('image/png'); - var imageName = getCardName() + '.png'; + var imageDataURL; + var imageName = getCardName(); + if (jpeg) { + imageDataURL = cardCanvas.toDataURL('image/jpeg', 0.8); + imageName = imageName + '.jpeg'; + } else { + imageDataURL = cardCanvas.toDataURL('image/png'); + imageName = imageName + '.png'; + } // Download image if (alt) { const newWindow = window.open('about:blank');