Created
July 1, 2024 13:32
-
-
Save Antosik/8a6c881adbd81cbdecc0e300b9d7c90c to your computer and use it in GitHub Desktop.
Image optimizer (OxiPNG, WebP, AVIF)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PNG_IMAGES := $(wildcard ./src/*/*.png ./src/*/*/*.png ./static/*/*.png ./static/*/*/*.png) | |
JPG_IMAGES := $(wildcard ./src/*/*.jpg ./src/*/*/*.jpg ./static/*/*.jpg ./static/*/*/*.jpg) | |
optimize-images: optimize-svg optimize-png optimize-avif optimize-webp | |
optimize-svg: | |
npx svgo --multipass -f ./src -r && \ | |
npx svgo --multipass -f ./static -r | |
optimize-png: | |
brew install oxipng && \ | |
oxipng -o 2 --strip safe $(PNG_IMAGES) | |
optimize-avif: | |
npx avif --lossless --overwrite --input="./src/**/**/*.{png,jpg}" && \ | |
npx avif --lossless --overwrite --input="./static/**/**/*.{png,jpg}" | |
optimize-webp: | |
brew install webp | |
$(foreach file, $(PNG_IMAGES), cwebp -mt -lossless $(file) -o $(file:.png=.webp);) | |
$(foreach file, $(JPG_IMAGES), cwebp -mt -lossless $(file) -o $(file:.jpg=.webp);) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment