mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-08 17:30:02 +02:00
⚡️ Copy images instead of regenerating them
This commit is contained in:
parent
d26f961d0a
commit
0b0cdd1487
1 changed files with 7 additions and 3 deletions
|
@ -7,6 +7,7 @@ import {
|
||||||
writeFileSync,
|
writeFileSync,
|
||||||
copyFileSync,
|
copyFileSync,
|
||||||
} from 'fs'
|
} from 'fs'
|
||||||
|
import { copyFile } from 'fs/promises'
|
||||||
import { dirname, extname, join } from 'path'
|
import { dirname, extname, join } from 'path'
|
||||||
import sharp from 'sharp'
|
import sharp from 'sharp'
|
||||||
|
|
||||||
|
@ -67,13 +68,16 @@ function constructConfig(name: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupImages(configPath: string, outputPath: string) {
|
async function setupImages(configPath: string, outputPath: string) {
|
||||||
|
// TODO: This can be made parallel to avoid problems with cpu vs disk access
|
||||||
for (const size of [16, 22, 24, 32, 48, 64, 128, 256]) {
|
for (const size of [16, 22, 24, 32, 48, 64, 128, 256]) {
|
||||||
await sharp(join(configPath, 'logo.png'))
|
await sharp(join(configPath, 'logo.png'))
|
||||||
.resize(size, size)
|
.resize(size, size)
|
||||||
.toFile(join(outputPath, `default${size}.png`))
|
.toFile(join(outputPath, `default${size}.png`))
|
||||||
await sharp(join(configPath, 'logo.png'))
|
|
||||||
.resize(size, size)
|
await copyFile(
|
||||||
.toFile(join(configPath, `logo${size}.png`))
|
join(outputPath, `default${size}.png`),
|
||||||
|
join(configPath, `logo${size}.png`)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
await sharp(join(configPath, 'logo.png'))
|
await sharp(join(configPath, 'logo.png'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue