Skip to content

Instantly share code, notes, and snippets.

@stiliajohny
Last active August 8, 2022 14:48
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 stiliajohny/3747fb558ce3a3c01b08661ea0b6a98c to your computer and use it in GitHub Desktop.
Save stiliajohny/3747fb558ce3a3c01b08661ea0b6a98c to your computer and use it in GitHub Desktop.
make avatar image
!#/bin/bash
# tile="arch.png"
# face_image="face.png"
tile="$1"
face_image="$2"
output="$3"
echo -e "Tile: ${tile}"
echo -e "Face: ${face}"
echo -e "Output: ${output}"
tile_percentage_vs_face=15
face_size=$(identify -format '%wx%h' $face_image)
face_size_x=$(identify -format '%h' $face_image)
face_size_y=$(identify -format '%w' $face_image)
title_x_perc=$(( face_size_x*tile_percentage_vs_face/100 ))
title_y_perc=$(( face_size_y*tile_percentage_vs_face/100 ))
# resize an image
convert $tile -resize ${title_x_perc}x${title_y_perc} ${tile}_resized.png
# tile the tile image
h2=`convert ${tile}_resized.png -format "%[fx:round(h/2)]" info:`
convert ${tile}_resized.png \( -clone 0 -roll +0+$h2 \) +append -write mpr:sometile +delete -size ${face_size} tile:mpr:sometile output.png
# overlay the two images
convert output.png ${face_image} -gravity center -composite ${output}
# clean
\rm output.png
\rm ${tile}_resized.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment