35 lines
1.4 KiB
Bash
35 lines
1.4 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# 게임 화면을 지금 게임 뷰의 크기 그대로 찍는다(UI 포함 · 검정 여백도 그대로). source shot.sh 뒤 shot <이름> [너비 높이]
|
||
|
|
# 너비 · 높이를 주지 않으면 실행 중인 게임의 화면 크기(Screen)를 물어서 쓴다 — 다른 크기로 찍으면 화면 구성이 달라진다
|
||
|
|
shot() {
|
||
|
|
local name="$1"; local w="$2"; local h="$3"
|
||
|
|
if [ -z "$w" ] || [ -z "$h" ]; then
|
||
|
|
local s=$(ev screen_size 2>&1 | head -1)
|
||
|
|
w=$(echo "$s" | cut -d' ' -f1); h=$(echo "$s" | cut -d' ' -f2)
|
||
|
|
fi
|
||
|
|
unity command capture_game_view --source screen --width "$w" --height "$h" --project-path "$P" --format json --no-banner 2>&1 | python -c "
|
||
|
|
import sys, json, base64, io
|
||
|
|
d = json.loads(sys.stdin.read())
|
||
|
|
r = (d.get('data') or {}).get('result') or {}
|
||
|
|
def find(o):
|
||
|
|
if isinstance(o, dict):
|
||
|
|
for k, v in o.items():
|
||
|
|
if isinstance(v, str) and len(v) > 1000: return v
|
||
|
|
f = find(v)
|
||
|
|
if f: return f
|
||
|
|
if isinstance(o, list):
|
||
|
|
for v in o:
|
||
|
|
f = find(v)
|
||
|
|
if f: return f
|
||
|
|
return None
|
||
|
|
b = find(r)
|
||
|
|
if not b:
|
||
|
|
print('NO IMAGE', json.dumps(d)[:400]); sys.exit(0)
|
||
|
|
from PIL import Image
|
||
|
|
im = Image.open(io.BytesIO(base64.b64decode(b))).convert('RGB')
|
||
|
|
gray = im.convert('L').point(lambda p: 255 if p > 10 else 0)
|
||
|
|
im.save(r'$SP/cap/$name.png')
|
||
|
|
print('saved $name', im.size, '검정이 아닌 영역', gray.getbbox())
|
||
|
|
"
|
||
|
|
}
|