-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtgs2gif-node.js
More file actions
executable file
·48 lines (39 loc) · 1.12 KB
/
tgs2gif-node.js
File metadata and controls
executable file
·48 lines (39 loc) · 1.12 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
const TGS = require('tgs-to');
const path = require('path');
const fs = require('fs');
if (process.argv.length < 3)
{
console.log('Usage: node tgs2gif-node.js input.tgs');
process.exit(1);
}
const input = process.argv[2];
if (!fs.existsSync(input))
{
console.log('❌ File not found:', input);
process.exit(1);
}
const now = new Date();
const timestamp = now.toISOString()
.replace(/[-:]/g, '')
.replace(/\..+/, '')
.replace('T', '-')
.substring(0, 15);
const basename = path.basename(input, '.tgs');
const output = path.join(path.dirname(input), `${basename}_${timestamp}.gif`);
const tgs = new TGS(input);
console.log('🎬 Converting TGS to GIF...');
tgs.convertToGif(output)
.then(() =>
{
console.log(`✅ Done: ${output}`);
// Move original to Trash
const trashPath = path.join(process.env.HOME, '.Trash', path.basename(input));
fs.renameSync(input, trashPath);
console.log('🗑 Moved original to Trash');
})
.catch(err =>
{
console.error('❌ Conversion failed:', err.message);
process.exit(1);
});