Skip to content

Instantly share code, notes, and snippets.

@cecil
Last active August 29, 2015 14:04
Show Gist options
  • Save cecil/8d583ac2d21e299446d0 to your computer and use it in GitHub Desktop.
Save cecil/8d583ac2d21e299446d0 to your computer and use it in GitHub Desktop.
imagemagick quick notes
function im-lowdepth {
# use imagemagick to lower the color depth of an image
# convert madmen_s04.jpg -depth 08 -colors 16 madmen_s04_d08_c16.jpg
FILEIN="$1"
filename=$(basename "$FILEIN")
extension="${filename##*.}"
filename="${filename%.*}"
for i in 08 16 32 64
do
convert ${FILEIN} -depth 8 -colors ${i} ${filename}_d08_c${i}.${extension}
done
}
function im-lowres {
# use imagemagick to lower the resolution of an image
# while keeping it the same dimensions
# TODO
# identify -format "%w x %h %x x %y\n" seiko_lv_submariner_yobokies.jpg
# $ convert seiko_lv_submariner_yobokies.jpg -resize 400x300 output.jpg
# $ convert output.jpg -resize 800x600 output1.jpg
# $ for i in seiko_lv_submariner_yobokies.jpg output.jpg output2.jpg ; do identify -format "%w x %h %x x %y\n" $i ; done
# 800 x 600 180 x 180
# 400 x 300 180 x 180
# 800 x 600 18 x 18
# this is not exactly what i'm looking for, maybe combined with lowering color depth
FILEIN="$1"
filename=$(basename "$FILEIN")
extension="${filename##*.}"
filename="${filename%.*}"
identify -format "%w x %h %x x %y" ${FILEIN}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment