Skip to content

Instantly share code, notes, and snippets.

@julianxhokaxhiu
Last active February 19, 2024 05:04
Show Gist options
  • Save julianxhokaxhiu/c0a8e813eabf9d6d9873 to your computer and use it in GitHub Desktop.
Save julianxhokaxhiu/c0a8e813eabf9d6d9873 to your computer and use it in GitHub Desktop.
Recursively optimize all PNG and JPG files wherever they are from the script position and inner ( based on OPTING, PNGCRUSH, ADVANCECOMP and JPEGOPTIM )
#!/bin/bash
# Improved as per feedback from @pascal - https://gist.github.com/julianxhokaxhiu/c0a8e813eabf9d6d9873#gistcomment-3086462
find . -type f -iname "*.png" -exec optipng -nb -nc {} \;
find . -type f -iname "*.png" -exec advpng -z4 {} \;
find . -type f -iname "*.png" -exec pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow {} \;
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec jpegoptim -f --strip-all {} \;
@greg-randall
Copy link

Unless you're using the AdvanceMame emulator to generate PNGs you can skip the advpng line. https://linux.die.net/man/1/advpng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment