Last active
August 29, 2015 13:56
-
-
Save dansku/9036386 to your computer and use it in GitHub Desktop.
Picture Resize, create original, smaller and thumbs to be used on a jekyll blog
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 | |
| #------------------------------------------------------- | |
| # Daniel Spillere Andrade - www.danielandrade.net | |
| # Script to Create Images for websites | |
| #------------------------------------------------------- | |
| #-- VARIABLES --# | |
| BIG=960000 | |
| SMALL=326900 | |
| TB="220x110" | |
| SNUM=1 # Start Number | |
| #-- Code Starts Here --# | |
| #Creating temporary folders | |
| mkdir thumb | |
| mkdir big | |
| mkdir small | |
| #Coping files (Copying the originals so we won't recompress) | |
| cp *.jpg big/ | |
| cp *.jpg small/ | |
| cp *.jpg thumb/ | |
| rm *.jpg | |
| #-- BIG FOLDER --------------------------# | |
| cd big | |
| echo "Creating big pictures" | |
| #Renaming | |
| a=$SNUM | |
| for i in *.jpg; do | |
| new=$(printf "pic%02d_o.jpg" ${a}) | |
| mv ${i} ${new} | |
| let a=a+1 | |
| done | |
| #Resizing | |
| for f in *.jpg | |
| do | |
| echo "Processing file: $f" | |
| convert $f -resize $BIG@ -colorspace RGB +sigmoidal-contrast 11.6933 -define filter:filter=Sinc -define filter:window=Jinc -define filter:lobes=3 -sigmoidal-contrast 11.6933 -colorspace sRGB $f | |
| done | |
| mv * .. | |
| #-- SMALL FOLDER --------------------------# | |
| cd ../small | |
| echo "Creating small pictures" | |
| #Renaming | |
| a=$SNUM | |
| for i in *.jpg; do | |
| new=$(printf "pic%02d.jpg" ${a}) | |
| mv ${i} ${new} | |
| let a=a+1 | |
| done | |
| #Resize Pics | |
| for f in *.jpg | |
| do | |
| echo "Processing file: $f" | |
| convert $f -resize $SMALL@ -colorspace RGB +sigmoidal-contrast 11.6933 -define filter:filter=Sinc -define filter:window=Jinc -define filter:lobes=3 -sigmoidal-contrast 11.6933 -colorspace sRGB $f | |
| done | |
| mv * .. | |
| #-- THUMBS FOLDER --------------------------# | |
| cd ../thumb | |
| echo "Creating thumb pictures" | |
| #Renaming | |
| a=$SNUM | |
| for i in *.jpg; do | |
| new=$(printf "pic%02d_tb.jpg" ${a}) | |
| mv ${i} ${new} | |
| let a=a+1 | |
| done | |
| #Resizing Pics | |
| for f in *.jpg | |
| do | |
| echo "Processing file: $f" | |
| convert $f -thumbnail $TB^ -gravity center -extent $TB $f | |
| done | |
| #------------------------------------------------ | |
| mv * .. | |
| cd .. | |
| rm -rf big/ thumb/ small/ | |
| echo "All done mister!" | |
| # The End! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment