lord help me why glsl
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/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<HEIGHT; y+=TILE_HEIGHT )); do
|
||||
for (( x=0; x<WIDTH; x+=TILE_WIDTH )); do
|
||||
|
||||
W=$(($TILE_WIDTH < $((WIDTH - x)) ? $TILE_WIDTH : $((WIDTH - x))))
|
||||
H=$(($TILE_HEIGHT < $((HEIGHT - y)) ? $TILE_HEIGHT : $((HEIGHT - y))))
|
||||
|
||||
# Filename encodes position: tile_x<x>_y<y>_w<W>_h<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."
|
||||
Reference in New Issue
Block a user