Skip to content

Instantly share code, notes, and snippets.

@tosiara
Created December 15, 2024 19:49
Show Gist options
  • Save tosiara/f12fc9a0a5fc4f2e375607298710ae50 to your computer and use it in GitHub Desktop.
Save tosiara/f12fc9a0a5fc4f2e375607298710ae50 to your computer and use it in GitHub Desktop.
Exctract faces and make collage out of them
i=0
for file in *.jpg; do
echo "$i $file"
name=$(basename "$file")
facedetect "$file" | while read x y w h; do
convert "$file" -crop ${w}x${h}+${x}+${y} -resize 640x640 "face_${i}.${name##*.}"
i=$((i+1))
done
i=$((i+1))
done
ls face_* -l | wc -l
montage -geometry +0+0 -tile 5x5 face*.jpg result.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment