#!/bin/bash # magick input.png -colorspace Gray -auto-level -dither FloydSteinberg -depth 8 output.png INPUT="$1" OUTPUT_DIR="tiles" #Create OUTPUT_DIR if it doesn't exist mkdir -p "$OUTPUT_DIR" #Get image dimensions WIDTH=$(identify -format "%w" "$INPUT") HEIGHT=$(identify -format "%h" "$INPUT") echo "Image dimensions: $WIDTH x $HEIGHT" #Tile dimensions TILE_WIDTH=8192 TILE_HEIGHT=8192 echo "Cutting image into tiles of ${TILE_WIDTH}x${TILE_HEIGHT}..." # Loop over vertical and horizontal positions count=0 for (( y=0; y_y_w_h.png TILE_FILE="$OUTPUT_DIR/tile_x${x}_y${y}_w${W}_h${H}.png" echo "Creating $TILE_FILE" # convert "$INPUT" -crop "${TILE_WIDTH}x${TILE_HEIGHT}+${x}+${y}" +repage "$TILE_FILE" vips extract_area "$INPUT" "$TILE_FILE" "$x" "$y" "$W" "$H" ((count++)) done done echo "Done. $count tiles created."