Skip to content

Instantly share code, notes, and snippets.

@fffej
Created March 26, 2025 17:38
Show Gist options
  • Select an option

  • Save fffej/f6389c7cebaeacb5c49817f30d93e45b to your computer and use it in GitHub Desktop.

Select an option

Save fffej/f6389c7cebaeacb5c49817f30d93e45b to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir -p Queen-Resized-BW Rook-resize-BW bishop_resized-BW knight-resize-BW pawn_resized-BW
for dir in Queen-Resized Rook-resize bishop_resized knight-resize pawn_resized; do
output_dir="${dir}-BW"
echo "Processing images in $dir..."
# Process each JPG in the directory
for img in "$dir"/*.jpg; do
# Get just the filename without path and extension
filename=$(basename "$img" .jpg)
echo " Converting $filename"
# Run Canny edge detection, resize to 64x64, convert to 1-bit black and white
convert "$img" \
-canny 0x1+10%+30% \
-resize 64x64! \
-monochrome \
"$output_dir/${filename}.png"
done
done
echo "Processing complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment