Initial commit
This commit is contained in:
commit
ec263707c7
80 changed files with 9928 additions and 0 deletions
34
fwt/Optimizers/OptimizeLogo.tsx
Normal file
34
fwt/Optimizers/OptimizeLogo.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import sharp from 'sharp'
|
||||
|
||||
interface Props {
|
||||
size?: number
|
||||
favicon?: boolean
|
||||
}
|
||||
|
||||
const convertLogo = async (props: Props) => {
|
||||
const inputSrc = 'src/assets/images/logo.png'
|
||||
const webpImage = 'fwt/images/logo.webp'
|
||||
const avifImage = 'fwt/images/logo.avif'
|
||||
|
||||
const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(props.size).toBuffer()
|
||||
await sharp(avifBuffer).toFile(avifImage)
|
||||
|
||||
const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(props.size).toBuffer()
|
||||
await sharp(webpBuffer).toFile(webpImage)
|
||||
}
|
||||
|
||||
const generateFavicon = async (props: Props) => {
|
||||
const inputSrc = 'src/assets/images/logo.png'
|
||||
const favicon = 'public/favicon.png'
|
||||
|
||||
const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(50).toBuffer()
|
||||
await sharp(faviconBuffer).toFile(favicon)
|
||||
}
|
||||
|
||||
export default (props: Props) => {
|
||||
convertLogo(props)
|
||||
|
||||
if (props.favicon) {
|
||||
generateFavicon(props)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue