Skip to content

Instantly share code, notes, and snippets.

@kana
Last active October 15, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kana/c4efaba000b3b33cbd55ccc8ca92a773 to your computer and use it in GitHub Desktop.
Save kana/c4efaba000b3b33cbd55ccc8ca92a773 to your computer and use it in GitHub Desktop.
ImageMagick usage
# Tweaked http://www.imagemagick.org/Usage/thumbnails/#rounded_border
convert -size 500x500 -alpha transparent xc:none -fill none -stroke black -strokewidth 4 -draw 'roundrectangle 1,1 498,498 12,12' ,border.png
convert -size 500x500 -alpha transparent xc:white -fill black -stroke transparent -strokewidth 4 -draw 'roundrectangle 0,0 499,499 12,12' ,mask.png
convert -background black src.jpg -resize '500^x500^' -gravity center -extent 500x500 -alpha set \
,mask.png -compose DstIn -composite \
,border.png -compose Over -composite \
bordered.jpg
# https://www.imagemagick.org/Usage/transform/#evaluate
convert rose: -alpha set -channel A -evaluate divide 2 rose_transparent.png
fs=($(ls [^t]*.jpg | shuf))
convert \( \
\( tt-${fs[0]} tt-${fs[1]} -append \) \
\( tt-${fs[2]} tt-${fs[3]} -append \) \
+append \
\) \
t-${fs[4]} \
\( \
\( tt-${fs[5]} tt-${fs[6]} -append \) \
\( tt-${fs[7]} tt-${fs[8]} -append \) \
+append \
\) \
+append \
,mosaic.jpg
# https://legacy.imagemagick.org/Usage/masking/#bg_remove
convert cyclops.png -bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 20% \
-fill none -floodfill +0+0 white \
-shave 1x1 cyclops_flood_3.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment