Update converter.js

This commit is contained in:
Kyle
2021-02-25 11:31:06 -08:00
parent 0813143165
commit 6bf9fd2f47

View File

@@ -31,17 +31,13 @@ async function cropCard(image, filename) {
// Determine version // Determine version
var version; var version;
if (context.getImageData(1342, 2026, 1, 1).data.toString() == '255,255,255,255') { if (context.getImageData(1342, 2026, 1, 1).data.toString() == '255,255,255,255') {
version = 'm15Noncreature';
} else if (context.getImageData(1342, 2062, 1, 1).data.toString() == '255,255,255,255') {
version = 'm15Creature';
} else {
version = 'none';
}
// Draw copyright info
if (version == 'm15Creature') {
context.drawImage(wizards, 895, 2009, 509, 25);
} else if (version == 'm15Noncreature') {
context.drawImage(wizards, 895, 1973, 509, 25); context.drawImage(wizards, 895, 1973, 509, 25);
} else if (context.getImageData(1342, 2020, 1, 1).data.toString() == '255,255,255,255') {
context.drawImage(wizards, 895, 1967, 509, 25);
} else if (context.getImageData(1342, 2062, 1, 1).data.toString() == '255,255,255,255') {
context.drawImage(wizards, 895, 2009, 509, 25);
} else if (context.getImageData(1342, 2056, 1, 1).data.toString() == '255,255,255,255') {
context.drawImage(wizards, 895, 2003, 509, 25);
} else { } else {
context.drawImage(wizards, 895, 2009, 509, 25); context.drawImage(wizards, 895, 2009, 509, 25);
notify('Your card type was unrecognized, and as such may have the copyright info incorrectly placed. Please double check your card.', 10); notify('Your card type was unrecognized, and as such may have the copyright info incorrectly placed. Please double check your card.', 10);
@@ -51,7 +47,7 @@ async function cropCard(image, filename) {
context.drawImage(cardMask, 0, 0, 1500, 2100); context.drawImage(cardMask, 0, 0, 1500, 2100);
// Download the card // Download the card
const download = document.createElement('a'); const download = document.createElement('a');
download.download = filename.replace('filename=', '') + '.png'; download.download = filename.replace('filename=', '');
download.href = canvas.toDataURL(); download.href = canvas.toDataURL();
document.body.appendChild(download); document.body.appendChild(download);
await download.click(); await download.click();