-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo.js
130 lines (121 loc) · 2.36 KB
/
demo.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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
'use strict'
const fs = require('fs')
const pMap = require('p-map')
const parse = require('csv-parse/lib/sync')
const render = require('.')
const quotesCsv = fs.readFileSync('example-input.csv')
const quotes = parse(quotesCsv, {
columns: true,
skip_empty_lines: true
})
const backgrounds = [
{
background: 'media/backgrounds/1.png',
style: {
padding: '25% 25% 30%',
color: '#ddb24a',
fontFamily: 'Caveat'
}
},
{
background: 'media/backgrounds/2.png',
style: {
padding: '20% 20% 25%',
color: '#ddb24a',
fontFamily: 'Sacramento'
}
},
{
background: 'media/backgrounds/3.png',
style: {
padding: '20% 20% 25%',
color: '#fff',
fontFamily: 'Dancing Script'
}
},
{
background: 'media/backgrounds/4.png',
quoteSize: 0.9,
style: {
padding: '36% 27% 40% 26%',
color: '#fff',
fontFamily: 'Great Vibes'
}
},
{
background: 'media/backgrounds/5.png',
style: {
padding: '30% 20% 20%',
color: '#fff',
fontFamily: 'Rochester'
}
},
{
background: 'media/backgrounds/6.png',
quoteSize: 0.8,
style: {
padding: '33% 15% 34% 17%',
color: '#fff',
fontFamily: 'Rochester'
}
},
{
background: 'media/backgrounds/7.png',
style: {
padding: '20%',
color: '#fff',
fontFamily: 'Calligraffitti'
}
},
{
background: 'media/backgrounds/8.png',
style: {
padding: '25%',
color: '#ddb24a',
fontFamily: 'Calligraffitti'
}
},
{
background: 'media/backgrounds/9.png',
style: {
padding: '20%',
color: '#fff',
fontFamily: 'Calligraffitti'
}
},
{
background: 'media/backgrounds/10.png',
style: {
padding: '30% 20% 20%',
color: '#ddb24a',
fontFamily: 'Calligraffitti'
}
}
]
const memes = []
for (let i = 0; i < quotes.length; ++i) {
const { Author, Quote } = quotes[i]
for (let j = 0; j < backgrounds.length; ++j) {
const bg = backgrounds[j]
const output = `media/output/quote-${i + 1}-bg-${j + 1}.png`
memes.push({
...bg,
output,
quote: Quote,
author: Author
})
}
}
async function main () {
await pMap(
memes,
async (meme) => {
console.log('render', meme)
return render(meme)
},
{
concurrency: 4
}
)
}
main()