-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresize.js
More file actions
30 lines (27 loc) · 808 Bytes
/
resize.js
File metadata and controls
30 lines (27 loc) · 808 Bytes
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
const Image = require('@11ty/eleventy-img')
const path = require('path')
const fs = require('fs')
;(async () => {
const files = fs.readdirSync('./src/images')
const format = 'jpg'
for (const filename of files) {
if (filename.substring(filename.length - 3) !== format) {
continue
}
const src = './src/images/' + filename
let metadata = await Image(src, {
widths: [null],
formats: ['jpeg'],
outputDir: './dist/temp/',
urlPath: '/images',
dryRun: false,
filenameFormat: function (id, src, width, format, options) {
const extension = path.extname(src)
const name = path.basename(src, extension)
// return `${name}-${width}w.${format}`
return `${name}.${format}`
},
})
console.log(metadata)
}
})()