Created
January 31, 2016 04:36
-
-
Save fabriziogiordano/9afb9337b266ab41d464 to your computer and use it in GitHub Desktop.
Convert a bunch of artboards in grayscale.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| folder_artboards="./artboards" | |
| folder_grayscale="./grayscale" | |
| folder_grayscale_opt="./grayscale_opt" | |
| # find $folder_grayscale -name "*.png" -type f -delete | |
| for i in $(find $folder_artboards -name "*.png" -type f); | |
| do | |
| base_name=$(basename "$i") | |
| date_source=`stat -f "%Sm" -t "%Y%m%d%H%M.%S" "$folder_artboards/$base_name"` | |
| if [ -f "$folder_grayscale/$base_name" ]; | |
| then | |
| date_grayscale=`stat -f "%Sm" -t "%Y%m%d%H%M.%S" "$folder_grayscale/$base_name"` | |
| if [ "$date_source" == "$date_grayscale" ]; | |
| then | |
| echo "Skip :: $base_name" | |
| continue | |
| fi | |
| fi | |
| # Imagemagick has some nice filters for gray scale | |
| convert \ | |
| "$folder_artboards/$base_name" \ | |
| -grayscale rec601luma \ | |
| "$folder_grayscale/$base_name" | |
| # In the process let's scale the image | |
| convert \ | |
| "$folder_grayscale/$base_name" \ | |
| -resize 50% \ | |
| "$folder_grayscale/$base_name" | |
| # Up to you to crush the png size | |
| #pngcrush -reduce -brute "$folder_grayscale/$base_name" "$folder_grayscale_opt/$base_name" | |
| touch -t "$date_source" "$folder_grayscale/$base_name" | |
| echo "Created :: $base_name" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment