minitech's solution to "Script to sepia tone and watermark images in a folder"

#!/bin/bash<\/span>\n\nif<\/span> [<\/span> $# <\/span>-ne 4<\/span> ]<\/span>;<\/span> then<\/span>\n    echo<\/span> &<\/span>quot;<\/span>Expected exactly 4<\/span> arguments.\nUsage: sepia <folder-path> <sepia-intensity> <text> <watermark-opacity>\nExample: ./sepia.bash my_images 70% \\&<\/span>quot;<\/span>A copyright\\&<\/span>quot;<\/span> 0.6&<\/span>quot;<\/span>\n    exit <\/span>1\nfi<\/span>\n\nfor<\/span> f in &<\/span>quot;<\/span>$1<\/span>&<\/span>quot;<\/span>/*.jp*g;<\/span> do<\/span>\n    output<\/span>=<\/span>&<\/span>quot;<\/span>${<\/span>f<\/span>%.*<\/span>}<\/span>_sepia.jpeg&<\/span>quot;<\/span>\n\n    if<\/span> ! echo<\/span> &<\/span>quot;<\/span>$f<\/span>&<\/span>quot;<\/span> |<\/span> grep _sepia > /dev/null;<\/span> then<\/span>\n        if<\/span> convert &<\/span>quot;<\/span>$f<\/span>&<\/span>quot;<\/span> -sepia-tone $2<\/span> -font Arial -pointsize 14<\/span> -draw &<\/span>quot;<\/span>gravity southeast fill black fill-opacity $4<\/span> text 10, 10<\/span> '$3'<\/span>&<\/span>quot;<\/span> &<\/span>quot;<\/span>$output<\/span>&<\/span>quot;;<\/span> then<\/span>\n            echo<\/span> &<\/span>quot;<\/span>Converted $f<\/span>.&<\/span>quot;<\/span>\n        else<\/span>\n            echo<\/span> &<\/span>quot;<\/span>Failed to convert $f<\/span>&<\/span>quot;<\/span>'!'<\/span>\n        fi<\/span>\n    fi<\/span>\ndone<\/span>\n<\/pre><\/div>\n

Today I learned bash scripting is hard!<\/p>\n

#!/bin/bash if [ $# -ne 4 ]; then echo "Expected exactly 4 arguments. Usage: sepia Example: ./sepia.bash my_images 70% \"A copyright\" 0.6" exit 1 fi for f in "$1"/*.jp*g; do output="${f%.*}_sepia.jpeg" if ! echo "$f" | grep _sepia > /dev/null; then if convert "$f" -sepia-tone $2 -font Arial -pointsize 14 -draw "gravity southeast fill black fill-opacity $4 text 10, 10 '$3'" "$output"; then echo "Converted $f." else echo "Failed to convert $f"'!' fi fi done Today I learned bash scripting is hard!! And make sure to `chmod +x sepia.bash`.
#!/bin/bash if [ $# -ne 4 ]; then echo "Expected exactly 4 arguments. Usage: sepia Example: ./sepia.bash my_images 70% \"A copyright\" 0.6" exit 1 fi if [ ! -d "$1/sepia" ]; then if ! mkdir "$1/sepia"; then echo "Failed to create directory $1/sepia." exit 1 fi fi for f in "$1"/*.jp*g; do base=$(basename "$f") output="${="$1/sepia/${base%.*}_sepia.jpeg" if ! echo "$f%.*}_sepia.jpeg" if ! echo "$f" | grep _sepia > /dev/null; then if convert "$f" -sepia-tone $2 -font Arial -pointsize 14 -draw "gravity southeast fill black fill-opacity $4 text 10, 10 '$3'" "$output"; then echo "Converted $f." else echo "Failed to convert $f"'!' fi fi done Today I learned bash scripting is hard! And make sure to `chmod +x sepia.bash`.

User: minitech

Question: Script to sepia tone and watermark images in a folder

Back to question