Skip to content

Instantly share code, notes, and snippets.

@dannyvankooten
Created April 26, 2026 06:15
Show Gist options
  • Select an option

  • Save dannyvankooten/843805fe19ec50827fd1bcdbd22f12d7 to your computer and use it in GitHub Desktop.

Select an option

Save dannyvankooten/843805fe19ec50827fd1bcdbd22f12d7 to your computer and use it in GitHub Desktop.
Run all images in wp-content/uploads through lossless compression.
# PNG files: optipng
find wp-content/uploads -name '*.png' -exec optipng {} +
# JPG files: jpegtran
find wp-content/uploads -name '*.jpg' -o -name '*.jpeg' | xargs -I{} jpegtran -copy none -optimize -outfile {} {}
# Webp: cwebp
find wp-content/uploads -name '*.webp' -exec cwebp -lossless {} -o {} \;
# GIF: gifiscle
find wp-content/uploads -name '*.gif' -exec gifsicle -O3 -b {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment