-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpme.js
More file actions
59 lines (53 loc) · 2.36 KB
/
helpme.js
File metadata and controls
59 lines (53 loc) · 2.36 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
49
50
51
52
53
54
55
56
57
58
59
var fs = require('fs'),
PNG = require('pngjs').PNG;
const dir = require('path').join(__dirname,'frames')
var basestr = ``
//const tonescale = ` .:-=+*#%@`.split('')
const tonescale = `,,,,,.....`.split('')
const possibilities = [256,230,220,200,180,160,140,130,120,100].reverse()
fs.writeFileSync('videodata.txt','')
let test = []
;(async()=>{
const f = await fs.promises.readdir(dir)
for(let i = 0;i<f.length;i++){
console.clear()
console.log('Converting frames into a table, please wait... (might take a while)')
console.log('Current frame: '+(i+1)+'/'+f.length)
file = 'frames/'+(i+1)+'.png'
let currentammount = 0
let currentcolor = tonescale[0]
await new Promise((res,err)=>{ //fiquei meia hora nessa merda
let thing = ""
test = []
fs.createReadStream(file)
.pipe(new PNG())
.on('parsed', function() {
for (let y = 0; y < this.height; y++) {
for (let x = 0; x < this.width; x++) {
let idx = (this.width * y + x) << 2; // (black - white / 0 - 255)(directly taken from the docs lmao)
for(const val of possibilities){
if(this.data[idx]<val) {
thing += tonescale[possibilities.indexOf(val)]
break;
/*if(currentcolor == tonescale[possibilities.indexOf(val)]){ //compressão pq tava coisando video em 480*360 e o node tava morrendo toda hr
currentammount++
} else {
thing += `${currentammount}_${currentcolor}|`
currentammount = 1
currentcolor = tonescale[possibilities.indexOf(val)]
}
break;*/
};
}
}
}
basestr += thing + '\n'
res()
})
.on('error',e=>err(e))
})
}
//require('child_process').spawn('clip').stdin.end(basestr);
//console.log('Coppied to clipboard!')
fs.writeFileSync('videodata.txt',basestr)
})();