Claude_Code_画像自動リサイズ_セットアップ手順
Claude Code 画像自動リサイズ セットアップ手順
「スクショ撮るだけで自動的に1800pxに縮小・Claude送信エラーゼロ。」
5分で導入できる macOS 自動化マニュアル。誰でも同じ環境を構築可能。
30秒で全体像
| 観点 | 一言 |
|---|---|
| 核心 | スクショ撮影 → 自動で1800px縮小 → Claudeに送ってもエラーゼロ |
| キーワード | LaunchAgent / sips / WatchPaths / ~/Pictures/Screenshots |
| 使う人 | Claude Code を頻繁に使う全員(macOSユーザー) |
| 読了目安 | 5分(セットアップ含めて10分) |
なぜ必要か
解決する問題
Claude API には画像サイズ制限がある:
- 1セッション内に複数画像があり
- そのうち1枚でも2000px超えなら
- → 以降の全プロンプトが詰まる(/handoff も /context も使えない)
詰まると致命的
- 進行中の作業が完全停止
- 引き継ぎメッセージも作れない
- 新セッションへ手動移行必要
- 過去の事例: 2026-05-05 SCALE CRM Zoom Phone 連携セッション全停止
この自動化で得られる効果
- スクショ撮影 → 自動で1800pxに縮小(数秒以内)
- 何も気にせず Claude にドラッグ可能
- API エラーゼロ
- 手動リサイズの手間なし
動作環境
| 項目 | 必要条件 |
|---|---|
| OS | macOS(Sequoia / Sonoma / Ventura で動作確認) |
| ターミナル | bash / zsh どちらでもOK |
| 必要権限 | なし(特別な権限・有料ソフト不要) |
| 必要ツール | macOS 標準(sips, launchctl)のみ |
セットアップ手順(5ステップ・約10分)
Step 1: ディレクトリ準備
# スクリプト保存先 + LaunchAgent + スクショ保存先
mkdir -p ~/.claude/scripts
mkdir -p ~/Library/LaunchAgents
mkdir -p ~/Pictures/Screenshots
Step 2: リサイズスクリプト作成
ファイル: ~/.claude/scripts/auto_resize_screenshots.sh
cat > ~/.claude/scripts/auto_resize_screenshots.sh <<'EOF'
#!/bin/bash
# 指定フォルダ内の最近作成されたPNG/JPGで2000px超のものを自動リサイズ
# 設定
WATCH_FOLDERS=("$HOME/Desktop" "$HOME/Downloads" "$HOME/Pictures/Screenshots")
MAX_SIZE=1800 # リサイズ後の最大px
THRESHOLD=2000 # この値超えたら対象
AGE_LIMIT=120 # 秒。これより古いファイルは対象外
LOG_FILE="$HOME/.claude/scripts/auto_resize.log"
# 少し待つ(ファイル書き込み完了待ち)
sleep 2
NOW=$(date +%s)
for FOLDER in "${WATCH_FOLDERS[@]}"; do
[ ! -d "$FOLDER" ] && continue
find "$FOLDER" -maxdepth 1 \
\( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" \) \
-not -name ".*" \
-type f \
2>/dev/null | while read FILE; do
MTIME=$(stat -f %m "$FILE" 2>/dev/null)
[ -z "$MTIME" ] && continue
AGE=$(( NOW - MTIME ))
[ "$AGE" -gt "$AGE_LIMIT" ] && continue
WIDTH=$(sips -g pixelWidth "$FILE" 2>/dev/null | awk '/pixelWidth/ {print $2}')
HEIGHT=$(sips -g pixelHeight "$FILE" 2>/dev/null | awk '/pixelHeight/ {print $2}')
[ -z "$WIDTH" ] && continue
[ -z "$HEIGHT" ] && continue
if [ "$WIDTH" -gt "$THRESHOLD" ] || [ "$HEIGHT" -gt "$THRESHOLD" ]; then
ORIG_SIZE=$(stat -f%z "$FILE" 2>/dev/null)
if sips -Z $MAX_SIZE "$FILE" >/dev/null 2>&1; then
NEW_WIDTH=$(sips -g pixelWidth "$FILE" 2>/dev/null | awk '/pixelWidth/ {print $2}')
NEW_SIZE=$(stat -f%z "$FILE" 2>/dev/null)
FILENAME=$(basename "$FILE")
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $FILENAME: ${WIDTH}x${HEIGHT} → ${NEW_WIDTH}px (${ORIG_SIZE}b → ${NEW_SIZE}b)" >> "$LOG_FILE"
osascript -e "display notification \"${WIDTH}x${HEIGHT} → ${NEW_WIDTH}px に縮小\" with title \"📸 自動リサイズ\" subtitle \"${FILENAME}\" sound name \"Pop\"" 2>/dev/null
fi
fi
done
done
exit 0
EOF
chmod +x ~/.claude/scripts/auto_resize_screenshots.sh
Step 3: LaunchAgent 設定ファイル作成
重要: ユーザー名を自分のものに置き換える(下記は oogushiyuuki の例)
# 自分のユーザー名を取得
USER_NAME=$(whoami)
echo "あなたのユーザー名: $USER_NAME"
# LaunchAgent 設定ファイル作成
cat > ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.scale.auto-resize-screenshots</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/${USER_NAME}/.claude/scripts/auto_resize_screenshots.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/${USER_NAME}/Desktop</string>
<string>/Users/${USER_NAME}/Downloads</string>
<string>/Users/${USER_NAME}/Pictures/Screenshots</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StandardOutPath</key>
<string>/Users/${USER_NAME}/.claude/scripts/auto_resize_stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/${USER_NAME}/.claude/scripts/auto_resize_stderr.log</string>
</dict>
</plist>
EOF
Step 4: LaunchAgent 起動
launchctl unload ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist 2>/dev/null
launchctl load ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
# 確認(com.scale.auto-resize-screenshots が表示されればOK)
launchctl list | grep auto-resize
Step 5: macOS 設定変更
スクショ保存先を変更
defaults write com.apple.screencapture location ~/Pictures/Screenshots
killall SystemUIServer
フローティングサムネイル無効化(推奨)
理由: サムネイル表示中はファイルがDesktopに保存されない → 自動リサイズが走らない
defaults write com.apple.screencapture show-thumbnail -bool false
killall SystemUIServer
動作確認(必須)
自動リサイズ動作テスト
# テスト用大画像作成(3000px)
TEST_FILE=~/Pictures/Screenshots/auto_test_$(date +%s).png
sips -s format png --resampleWidth 3000 /System/Library/CoreServices/DefaultDesktop.heic --out "$TEST_FILE" 2>/dev/null
echo "テスト前: $(sips -g pixelWidth "$TEST_FILE" | awk '/pixelWidth/ {print $2}')px"
# 8秒待機
sleep 8
# サイズ確認
NEW_WIDTH=$(sips -g pixelWidth "$TEST_FILE" | awk '/pixelWidth/ {print $2}')
echo "テスト後: ${NEW_WIDTH}px"
if [ "$NEW_WIDTH" -le 2000 ]; then
echo "✅ 自動リサイズ成功!"
else
echo "❌ 失敗。トラブルシューティング参照"
fi
# テストファイル削除
rm -f "$TEST_FILE"
期待結果: ✅ 自動リサイズ成功!
使い方
通常の運用フロー
1. Cmd+Shift+3/4/5 でスクショ撮影
↓
2. ~/Pictures/Screenshots/ に自動保存
↓
3. 自動リサイズ実行(数秒)
↓
4. macOS 通知「📸 自動リサイズ」
↓
5. Finder で ~/Pictures/Screenshots/ から Claude にドラッグ
↓
6. リサイズ済み画像でアップロード ✅
Finder サイドバーに追加(推奨)
ワンクリックでスクショフォルダにアクセス:
1. Finder で ~/Pictures/Screenshots を開く
2. サイドバーにドラッグして固定
カスタマイズ
リサイズ後のサイズ変更
ファイル: ~/.claude/scripts/auto_resize_screenshots.sh
MAX_SIZE=1800 # ここを 1500 や 2000 に変更可能
変更後はLaunchAgent再起動不要(次回スクショから反映)
監視フォルダ追加
ファイル: ~/.claude/scripts/auto_resize_screenshots.sh
WATCH_FOLDERS=("$HOME/Desktop" "$HOME/Downloads" "$HOME/Pictures/Screenshots" "$HOME/任意のフォルダ")
ファイル: ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
<key>WatchPaths</key>
<array>
<string>/Users/USER/Desktop</string>
<string>/Users/USER/Downloads</string>
<string>/Users/USER/Pictures/Screenshots</string>
<string>/Users/USER/任意のフォルダ</string> <!-- ここ追加 -->
</array>
変更後は LaunchAgent 再起動:
launchctl unload ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
launchctl load ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
一時停止 / 再開
一時停止
launchctl unload ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
再開
launchctl load ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
完全アンインストール
# LaunchAgent停止・削除
launchctl unload ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
rm ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist
# スクリプト削除
rm ~/.claude/scripts/auto_resize_screenshots.sh
rm ~/.claude/scripts/auto_resize.log
rm ~/.claude/scripts/auto_resize_stdout.log
rm ~/.claude/scripts/auto_resize_stderr.log
# macOS 設定を元に戻す
defaults write com.apple.screencapture location ~/Desktop
defaults write com.apple.screencapture show-thumbnail -bool true
killall SystemUIServer
トラブルシューティング
Q. 自動リサイズが動かない
A1. LaunchAgent が登録されているか確認
launchctl list | grep auto-resize
何も表示されない → Step 4 やり直し
A2. スクリプト直接実行で動くか確認
~/.claude/scripts/auto_resize_screenshots.sh
echo "exit code: $?"
exit code が 0 以外 → スクリプトに問題あり
A3. ログ確認
cat ~/.claude/scripts/auto_resize.log
cat ~/.claude/scripts/auto_resize_stderr.log
エラーメッセージから原因特定
A4. ファイルが古い(120秒以上前)
スクリプトは過去2分以内のファイルのみ対象。古い画像は触らない仕様。
Q. 通知が出ない
A. システム設定 → 通知 → "ターミナル" or "スクリプトエディタ" の通知許可確認
Q. フローティングサムネイルが残ってると自動リサイズ走らない
A. ご指摘の通り。Step 5 の「フローティングサムネイル無効化」を必ず実行
サムネイル表示中はファイルがメモリ上にあり、Desktop に保存されない。
サムネイルからアプリへ直接ドラッグ=Desktop経由しない=自動リサイズ対象外。
Q. スクショ以外の画像(DLや作業中)も勝手にリサイズされる
A. 仕様。回避するには:
- WATCH_FOLDERS から該当フォルダを除外
- AGE_LIMIT を短く(例: 30秒)して即時撮影のみ対象に
設置ファイル一覧
| ファイル | 役割 |
|---|---|
~/.claude/scripts/auto_resize_screenshots.sh |
リサイズ実行スクリプト |
~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist |
LaunchAgent定義 |
~/.claude/scripts/auto_resize.log |
リサイズ履歴 |
~/.claude/scripts/auto_resize_stdout.log |
LaunchAgent標準出力 |
~/.claude/scripts/auto_resize_stderr.log |
LaunchAgentエラー出力 |
~/Pictures/Screenshots/ |
スクショ保存先(macOS設定変更で) |
メリット・デメリット
メリット
- スクショ撮るだけで自動処理(手動リサイズ不要)
- Claude API エラーゼロ
- macOS標準ツールのみ使用(追加インストール不要)
- 任意のタイミングで一時停止・再開可能
- ログで動作履歴確認可能
デメリット
- フローティングサムネイル機能を諦める必要あり
- 監視フォルダ内の他の画像も対象になる(カスタマイズで除外可)
- リサイズは「オリジナル上書き」(バックアップ取らない)
FAQ
Q. 元の高解像度を保持したい場合は?
A. WATCH_FOLDERS から除外したフォルダに保存
- 例: ~/Pictures/Originals/ に保存 → 自動リサイズされない
- スクショ用途なら 1800px で十分(Retinaでも見やすい)
Q. 他のMacで同じ設定したい
A. 設定ファイル2つコピーすればOK
1. ~/.claude/scripts/auto_resize_screenshots.sh
2. ~/Library/LaunchAgents/com.scale.auto-resize-screenshots.plist(ユーザー名修正)
両方コピー後、Step 4 の launchctl load 実行で完了。
Q. iPhone のスクショは対象?
A. iPhone から直接は対象外。
ただし AirDrop や iCloud 経由で Mac に来た画像は、Downloads / Desktop に入れば対象。
関連ナレッジ
- Claude Code 容量不足対策(このノートの親)
- 最強1日ルーティン(生産性最大化)
- グローバル CLAUDE.md(
~/.claude/CLAUDE.md)
改訂履歴
| 日付 | 内容 |
|---|---|
| 2026-05-05 | 初版作成。SCALE社員・Claude Codeユーザー向けセットアップマニュアル化 |