Created
March 23, 2023 19:24
-
-
Save SKaplanOfficial/ddae514c42371b3ccee8ffc9be63e496 to your computer and use it in GitHub Desktop.
AppleScriptObjC script to get the payload value of QR codes in images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use framework "CoreImage" | |
on getQRPayload(imagePath) | |
set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:imagePath | |
set theCIImage to current application's CIImage's imageWithData:(theImage's TIFFRepresentation()) | |
set theDetector to my (CIDetector's detectorOfType:(my CIDetectorTypeQRCode) context:(my CIContext's context()) options:(missing value)) | |
set theFeatures to theDetector's featuresInImage:theCIImage | |
set theResult to "" | |
repeat with theFeature in theFeatures | |
set theResult to theResult & theFeature's messageString() & ", " | |
end repeat | |
if length of theResult > 0 then | |
set theResult to text 1 thru ((length of theResult) - 2) of theResult | |
end if | |
return theResult | |
end getQRPayload | |
return getQRPayload("/Users/exampleUser/Downloads/image.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment