Skip to content

Instantly share code, notes, and snippets.

@keiya
Created June 6, 2015 13:10
Show Gist options
  • Select an option

  • Save keiya/4dc1c1359e23bb53576d to your computer and use it in GitHub Desktop.

Select an option

Save keiya/4dc1c1359e23bb53576d to your computer and use it in GitHub Desktop.
compress large uncompressed or lossless format into compressed/lossy format. // powered by imagemagick
#!/bin/bash
CONV='/usr/bin/convert.exe'
#find "$1" -type f \( -iname "*.bmp" \) -print0 | while IFS= read -r -d '' fullfile; do # BMP->PNG (Lossless)
find "$1" -type f \( -iname "*.bmp" -o -iname "*.png" \) -print0 | while IFS= read -r -d '' fullfile; do # any Lossless to Lossy JPEG
#$CONV "${fullfile}" "${fullfile}.png" && rm -f "${fullfile}" # BMP->PNG (Lossless)
$CONV -quality 80 "${fullfile}" "${fullfile}.jpg" && rm -f "${fullfile}" # any Lossless to Lossy JPEG
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment