Last active
August 2, 2019 07:12
-
-
Save OrderAndCh4oS/441610e5219f4cacbd501363fcc734c3 to your computer and use it in GitHub Desktop.
ImageMagick Bash Scripts
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
# flatColourConvert image.png red | |
function flatColourConvert() { | |
magick convert "$1" -fill "$2" -colorize 100% x.png | |
} | |
# replaceColours "#1B3057" "#2B373D" | |
# replaceColours red "#2B373D" 70% | |
function replaceColours() { | |
magick convert *.png -set filename:original %t -channel RGB -fuzz ${3:-25%} -fill $1 -opaque $2 %[filename:original].png | |
} | |
# smartResize "2400x2400>" | |
function smartResize() { | |
find ./ \( -name "*.[Jj][Pp][Gg]" -o -name "*.[Jj][Pp][Ee][Gg]" \) -exec magick mogrify -resize $1 -sampling-factor 4:2:0 -strip -interlace JPEG -quality 85 -colorspace RGB {} \; | |
find ./ \( -name "*.[Pp][Nn][Gg]" \) -exec magick mogrify -strip -resize $1 '{}' \; | |
} | |
# makeThumbPng 100x100> | |
function makeThumbPng() { | |
find ./ \( -name "*.[Pp][Nn][Gg]" \) -exec sh -c 'magick convert -strip -resize $1 "$0" "${0%.*}-$1.png"' {} $1 \; | |
} | |
# makeThumbJpg 2400x2400> | |
function make-thumb-jpg() { | |
find ./ \( -name "*.[Jj][Pp][Gg]" -o -name "*.[Jj][Pp][Ee][Gg]" \) -exec sh -c 'magick convert -resize $1 -sampling-factor 4:2:0 -strip -interlace JPEG -quality 85 -colorspace RGB "$0" "${0%.*}-$1.jpg"' {} $1 \; | |
} | |
# stackHoverOvers | |
# Expects files named like icon-off.png and icon-on.png | |
# Combines and stacks vertically for smooth rollovers | |
function stackHoverOvers() { | |
for i in *-off.png ; | |
do | |
OFF="$i" | |
NAME=${OFF%-off.png} | |
ON=$NAME"-on.png" | |
magick convert -append $OFF $ON $NAME".png" | |
done | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment