forked from a-lew/360-tool-sketchfab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_png_to_ktx.js
31 lines (29 loc) · 995 Bytes
/
convert_png_to_ktx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const util = require('node:util')
const exec = util.promisify(require('node:child_process').exec)
const main = async () => {
const downloads_dir = 'full path to downloads location'
const acc_num = 'accession number';
for (let i = 0; i < 750; i++) {
const file_derivative = JSON.stringify(i).padStart(4, '0');
const base_path = `${downloads_dir}/${acc_num}`;
const file_name = `${acc_num}_${file_derivative}`
const input_file = `${base_path}/${file_name}.png`
const output_file = `${base_path}/${file_name}.ktx`
const cmd = `PVRTexToolCLI -i ${input_file} -o ${output_file} -f PVRTC2_4`
const { stdout, stderr, error } = await (exec(cmd));
if (error) {
console.error(error)
process.exit(1)
}
if (stdout) {
console.log(stdout)
}
if (stderr) {
console.log(stderr)
}
}
if (i === 750) {
process.exit(0)
}
}
main();