Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Last active February 28, 2023 02:12
Show Gist options
  • Select an option

  • Save benigumocom/b98f899af8ad674905fd0e807d122f1a to your computer and use it in GitHub Desktop.

Select an option

Save benigumocom/b98f899af8ad674905fd0e807d122f1a to your computer and use it in GitHub Desktop.
#!/bin/bash
screencapture -i -c -o
tmp_file=$(mktemp -t qr_code.XXXXXXXXXX).png
osascript <<EOF
set png_data to the clipboard as «class PNGf»
set the_file to open for access POSIX path of (POSIX file "$tmp_file") with write permission
write png_data to the_file
close access the_file
EOF
text=$(zbarimg --quiet --raw "$tmp_file")
# text=$(zxing -c "$tmp_file" | tail -n +2 | cut -d , -f 4) # only first detected
if [ -n "$text" ]; then
echo "$text"
else
echo "No QR code found in selection."
fi
# qlmanage -p "$tmp_file" >& /dev/null # show captured image
rm "$tmp_file"
@benigumocom
Copy link
Copy Markdown
Author

【スマホ・カメラ不要】Mac上でQRコードを スクリーンキャプチャ→テキスト化 するスクリプト
👉 https://android.benigumo.com/20230227/mac-qr-reader/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment