Skip to content

Instantly share code, notes, and snippets.

@liunian
Last active April 21, 2023 14:25
Show Gist options
  • Save liunian/0434f0319e36623552aee4dd80457f88 to your computer and use it in GitHub Desktop.
Save liunian/0434f0319e36623552aee4dd80457f88 to your computer and use it in GitHub Desktop.
optimize images
#!/usr/bin/env fish
# use optipng to optimize png
if type -q optipng
set pngs (command find . -name "*.png")
for i in $pngs
# echo $i
optipng -strip all $i
end
else
echo "optipng is not installed yet"
end
# use jpegoptim to optimize jpeg
if type -q jpegoptim
set jpegs (command find . -name "*.jpeg" -or -name "*.jpg")
for i in $jpegs
# echo $i
jpegoptim -s $i
end
else
echo "jpegoptim is not installed yet"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment