Created
May 2, 2023 10:26
-
-
Save kkotaro0111/606dde104cabf6437352000ba7e04db2 to your computer and use it in GitHub Desktop.
カレントディレクトリ以下にあるJPG/PNG/SVGを最適化し、../resized というディレクトリに階層を維持したまま保存するマン
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
#!/bin/bash | |
mkdir -p ../resized | |
JPG=$(find . -name '*.jpg' -type f) | |
PNG=$(find . -name '*.png' -type f) | |
SVG=$(find . -name '*.svg' -type f) | |
for img in $JPG | |
do | |
echo 'JPG: '$img | |
img=$(echo $img | sed 's!^./!!') | |
mkdir -p `dirname ../resized/$img` | |
djpeg $img | cjpeg -optimize > ../resized/$img | |
done | |
for img in $SVG | |
do | |
echo 'SVG: '$img | |
img=$(echo $img | sed 's!^./!!') | |
mkdir -p `dirname ../resized/$img` | |
svgo $img -o ../resized/$img | |
done | |
for img in $PNG | |
do | |
echo 'PNG: '$img | |
img=$(echo $img | sed 's!^./!!') | |
mkdir -p `dirname ../resized/$img` | |
zopflipng --lossy_transparent --lossy_8bit --iterations=20 --filters=0me $img ../resized/$img | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment