Last active
January 31, 2016 23:31
-
-
Save xpac27/da1dc009d16bccc593d2 to your computer and use it in GitHub Desktop.
Prepare images for Francoiscogne.com's backoffice
This file contains 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 | |
# Requires: brew install imagemagick --with-little-cms --with-little-cms2 | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
echo "" | |
echo "" | |
echo "" | |
echo "" | |
echo "All the images in the following folder will be changes: " | |
echo "" | |
echo " $DIR" | |
echo "" | |
read -p "Do you want to continue? (Y/n)" answer | |
if [ "$answer" != "Y" ]; then | |
echo "Aborded!" | |
exit 1 | |
fi | |
# CONVERT EPS files to JPG | |
find "$DIR" -iname "*.eps" | sed 's/^.\///g' | while read i | |
do | |
echo "converting to JPG ($i)" | |
JPG=`echo "$i" | sed "s/.eps$/.jpg/"` | |
`convert -density 300 "$i" "$JPG"` | |
`rm "$i"` | |
done | |
# Convert PNG files to JPG | |
find "$DIR" -iname "*.png" | sed 's/^.\///g' | while read i | |
do | |
echo "converting to JPG ($i)" | |
JPG=`echo "$i" | sed "s/.png$/.jpg/"` | |
`convert "$i" -background white -flatten "$JPG"` | |
`rm "$i"` | |
done | |
# Convert PSD files to JPG | |
find "$DIR" -iname "*.psd" | sed 's/^.\///g' | while read i | |
do | |
echo "converting to JPG ($i)" | |
JPG=`echo "$i" | sed "s/.psd$/.jpg/"` | |
`convert "$i[0]" -auto-orient -alpha Off "$JPG"` | |
`rm "$i"` | |
done | |
# Convert TIFF files to JPG | |
find "$DIR" -iname "*.tif" | sed 's/^.\///g' | while read i | |
do | |
echo "converting to JPG ($i)" | |
JPG=`echo "$i" | sed "s/.tif$/.jpg/"` | |
`convert "$i" -background white -flatten "$JPG"` | |
`rm "$i"` | |
done | |
# Preparing all JPG files | |
find "$DIR" -iname "*.jpg" -or -iname "*.jpeg" | sed 's/^.\///g' | while read i | |
do | |
echo "preparing ($i)" | |
`convert "$i" -colorspace RGB -trim -strip -profile "$DIR/sRGB_IEC61966-2-1_black_scaled.icc" -resize 1200x1200 -density 72 -quality 90 "$i"` | |
done | |
echo "" | |
echo "All done! you can close this window." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment