blog/dither.sh
2021-05-29 17:19:29 +02:00

14 lines
543 B
Bash
Executable File

# Dither images present in the blog, moving the existing images to filename_original.jpg
## Travel down the directory content/
find content/ \ # Find from the content directory
-maxdepth 4 \ # Maximu depth of 4 dirs
-type f \ # Find only files
-name "*.jpg" \ # Find only JPEG files
-exec \ # Execute next lines
cp {} {}.original && \ # Copy file and add .original to it's filename
convert {} -colorspace GRAY -o ordered-dither o2x2 {}\ # Dither image
jpegoptim {} -S 80 -t && \ # Optimize the jpeg file
; # Finish