Skip to content

Instantly share code, notes, and snippets.

@georgy7
Last active February 4, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgy7/f52a8bb362afec91ec81dfade0a18676 to your computer and use it in GitHub Desktop.
Save georgy7/f52a8bb362afec91ec81dfade0a18676 to your computer and use it in GitHub Desktop.
Strange JPEGs (CMYK, for instance) to normal JPEGs
trap '
trap - INT # restore default INT handler
kill -s INT "$$"
' INT
INPUT=StockByte
OUTPUT=StockByte_simple_jpeg
# It scans subfolders recursively, but...
shopt -s globstar
for f in \
$INPUT/*.jpg $INPUT/**/*.jpg \
$INPUT/*.JPG $INPUT/**/*.JPG \
$INPUT/*.jpeg $INPUT/**/*.jpeg \
$INPUT/*.JPEG $INPUT/**/*.JPEG
do
if [ -f "$f" ]; then
echo " Hi! $f"
SIMPLENAME=$(basename "$f")
# ...places all the files into the single directory.
convert "$f" -colorspace sRGB "$OUTPUT/$SIMPLENAME"
fi
done
for F in StockByte_simple_jpeg/*; do cwebp -q 24 "$F" -o StockByte_webp_q24/$(basename "$F").webp ; done
for F in StockByte_simple_jpeg/*; do cwebp -lossless "$F" -o StockByte_webp_lossless/$(basename "$F").webp ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment