| 11 | const { current, versions } = require("./consts"); |
| 12 | |
| 13 | export async function createWallpaper( |
| 14 | inputDirectory: string, |
| 15 | outputDirectory: string, |
| 16 | file: string, |
| 17 | width: number, |
| 18 | height: number |
| 19 | ) { |
| 20 | const outputFile = `${outputDirectory}/${ |
| 21 | path.parse(file).name |
| 22 | }-${width}-${height}.jpg`; |
| 23 | if (fs.existsSync(outputFile)) { |
| 24 | // File exists in path |
| 25 | } else { |
| 26 | await sharp(`${inputDirectory}/${file}`) |
| 27 | .resize(width, height, { fit: "cover" }) |
| 28 | .jpeg({ mozjpeg: true, quality: 100 }) |
| 29 | .toFile(outputFile); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | async function createWallpapers() { |
| 34 | const inputDirectory = path.join(process.cwd(), "data", "wallpapers"); |