-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddimg.sh
More file actions
67 lines (57 loc) · 1.54 KB
/
addimg.sh
File metadata and controls
67 lines (57 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
SCREENSHOT_DIR="$HOME/Documents/RetroArch/screenshots"
USAGE="Usage: sh addimg.sh [-g|--grayscale] <row>,<col>"
# Parse options: -g | --grayscale
grayscale=false
while [ "${1:-}" != "" ]; do
case "$1" in
-g|--grayscale)
grayscale=true
shift
;;
-h|--help)
echo "$USAGE"
exit 0
;;
--)
shift
break
;;
-*)
echo "Unknown option: $1"
exit 1
;;
*)
break
;;
esac
done
coords="$1"
if [ -z "$coords" ]; then
echo "$USAGE"
exit 1
fi
# Parse coordinates: keep column as letter (e.g., "9,F" -> "9,F")
row=$(echo "$coords" | cut -d, -f1)
col=$(echo "$coords" | cut -d, -f2)
if [ -z "$row" ] || [ -z "$col" ]; then
echo "Invalid coordinate format. Use: row,column (e.g., 9,F)"
exit 1
fi
# Find the last screenshot for this ROM
cd "$SCREENSHOT_DIR" || { echo "Screenshot directory not found: $SCREENSHOT_DIR"; exit 1; }
filename=$(ls Golden\ Axe\ Warrior*.png 2>/dev/null | tail -n 1)
if [ -z "$filename" ]; then
echo "No Golden Axe Warrior*.png file found."
exit 1
fi
# Crop, resize, and process image; add grayscale when requested
magick_args=("$filename" -crop 2048x1280+0+0 +repage -resize 256x160 -interpolate bilinear -filter point)
if [ "$grayscale" = true ]; then
magick_args+=(-colorspace Gray)
fi
magick "${magick_args[@]}" output.png
# Move output to target directory with letter filename (e.g., 9_F.png)
mv output.png ~/Documents/GAW/imgs/"${row}_${col}".png
# Delete the chosen screenshot since it has been processed
rm "$filename"