Skip to content

Commit

Permalink
Decode image script
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Jun 13, 2022
1 parent 1cee643 commit 6e292ed
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/decode-image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright (c) 2022 Daniel Imms <http://www.growingwiththeweb.com>
* Released under MIT license. See LICENSE in the project root for details.
*/

const decoder = require('..');
const fs = require('fs/promises');
const { extname } = require('path');

async function decode(file) {
if (extname(file) !== '.tga') {
throw new Error('File must end with .tga');
}
const originalData = await fs.readFile(file);
const decoded = await decoder.decodeTga(originalData);
console.log(`Decoded "${file}":`, decoded);
}

if (process.argv.length < 3) {
console.error('Provide a file as the first argument');
process.exit(1);
}

decode(process.argv[2]);

0 comments on commit 6e292ed

Please sign in to comment.