QR Code Shortcut

A thread (here) contains a link to an article that discusses eleven advanced shortcuts, and one of these creates a QR code from various inputs. If the link to the article becomes unavailable, or if a forum member just wants to view the basics, I’ve included below a simple shortcut that creates a QR code from text (which includes a URL).

QR Code.shortcut (22.3 KB)

A Shortcut action that reads a QR code is not available, but scripts that will do this are available here. The following is a minor rewrite of a handler by Fredrik71, and it works well in my testing:

use framework "Foundation"
use framework "QuartzCore"
use scripting additions

set theImage to choose file of type {"public.image"} with prompt "Select an image with a QR code"
set theText to textFromQR(theImage) -- add error correction

on textFromQR(theImage) -- a minor rewrite of a handler by Fredrik71
	set imageURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of theImage)
	set imageRef to current application's CIImage's alloc()'s initWithContentsOfURL:imageURL
	set optionsDictionary to current application's NSDictionary's dictionaryWithObject:"CIDetectorAccuracyHigh" forKey:"CIDetectorAccuracy"
	set theDetector to current application's CIDetector's detectorOfType:"CIDetectorTypeQRCode" context:(missing value) options:optionsDictionary
	set theFeature to theDetector's featuresInImage:imageRef options:optionsDictionary
	return (theFeature's firstObject())'s messageString() as text
end textFromQR