A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

Related tags

Image QRDecode
Overview

QRDecode

A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

QRDecode is

A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

You can also drop files on the app icon, in the file system or in the dock.

You can use the app's open dialog box.

You can specify complete file paths on the command line, except it doesn't work because the sandboxing doesn't let you arbitrary points in the file system.

Theory of operation:

  • TopView handles the layout, laying out an imageView above a scrollable textView.
  • ImageView is a subclass of NSImageView - it responds to dropping an image file onto it. When you assign an NSImage to it, it tries to find and delegates to QRCodeDecoder to decode any QRCodes in the image as well as all the normal NSImageView stuff. If it finds any it calls its delegate method with the payload string.
  • QRDecoder decodes an image, calling its QRDelegate delegate with the decoded result.
  • TextViewDelegatablePaste is a subclass of NSTextView - if the pasteboard has an image, it calls paste on its PateDelegate delegate rather than passing it on to NSTextView.
  • QRViewController holds and organizes all of the above.

Lessons learned:

  • Opening files from the dock icon:
    • I couldn't connect the viewController to the appDelegate in interface builder, but following the ownership chain seems to work at run time.
    • To open from the doc icon, I had to set up my Info.plist correctly - I used the reference doc to figure it out UTIs there
  • Opening files the open dialog: I had to figure out UTIs again.
  • Opening files the drop destination: I had to figure out UTIs yet again.
  • Open Recent works by registering it with the correct NSDocumentController api.
  • I couldn't get layout constraints to work properly (window filled screen on drop. (TextView wouldn't let me type)) so I just got rid of them and did the layout in TopView.
  • drop destination handling was not obvious.
  • Actual QRCode scanning was not obvious: I needed to create a handler that references the image, and hand it a request.
  • Xcode injects additional arguments into the command line like
$ myProgram -NSDocumentRevisionsDebugMode YES
  • Opening files from the command-line doesn't work because of sandboxing. It would work if sandboxing were turned off.
  • NSTextView, as firstResponder, disallows pasting images so QRViewController never gets a chance to see the paste. I wrote TextViewDelegatablePaste, a subclass of NSTextView, to handle pasting images into QRViewController.

License

Apache 2 - Open Source

You might also like...
Simple CLI utility to save off an image from every webcam hooked into a mac

macOSCameraCapture Simple CLI utility to save off an image from every webcam connected to the macOS machine. This utility is meant for research and te

Mobile Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP)
Mobile Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP)

A Mobile Text-to-Image Search Powered by AI A minimal demo demonstrating semantic multimodal text-to-image search using pretrained vision-language mod

Mobile(iOS) Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP)
Mobile(iOS) Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP)

Mobile Text-to-Image Search(MoTIS) MoTIS is a minimal demo demonstrating semantic multimodal text-to-image search using pretrained vision-language mod

TextDrawer, is a UIView allows you to add text, with gesture, on UIView, or UIImage
TextDrawer, is a UIView allows you to add text, with gesture, on UIView, or UIImage

TextDrawer TextDrawer, is a UIView allows you to add text, with gesture, on UIView, or UIImage. About Annotating Images TextDrawer is the easiest way

Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.

I've built out the Swift version of this library! Screenshots Description ABMediaView can display images, videos, as well as now GIFs and Audio! It su

An app show your Live Photo and export as GIF.
An app show your Live Photo and export as GIF.

LivelyGIFs Show your Live Photo and export as GIF. Demo HighLights Do not use Pod or Cathage to install 3rd party library Simple logic, new learner fr

Read colors from Xcode assets file.

XcodePalette Read colors from Xcode assets file. How to Use Download the XcodePalette.Executable.zip of the latest release. Extract the XcodePalette U

Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

📷 A composable image editor using Core Image and Metal.
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component 🎉 v2.0.0-alpha now open!

Owner
David Phillip Oster
David Phillip Oster
Create an '.icns' file from any image

createicns Create an '.icns' file from any image. Usage This command line tool makes it incredibly simple to create an '.icns' icon file from an image

Jordan Baird 6 Aug 21, 2022
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

Adnan Yousaf 11 Jan 10, 2022
A Fast and Complete Swift Drawing Library

FastDraw A Fast and Complete Swift Drawing Library Description FastDraw is a high performance and highly extensible Drawing Library that supports Appl

Collin Zhang 18 Nov 14, 2022
The repository for a command line / build pipeline tool for generating colors from a human-readable text file that designers can also use.

ColorPaletteGenerator ColorPaletteGenerator is a tool that takes a human-readable input file describing a color palette, and generates the associated

horseshoe7 0 Dec 7, 2021
XIV-on-Mac - Wine Wrapper, Setup tool and launcher for FFXIV on mac

XIV on Mac Wine Wrapper, Setup tool and alternative launcher for FFXIV on MacOS.

null 210 Dec 26, 2022
ZImageCropper is a simplest way to crop image to any shapes you like.

ZImageCropper ZImageCropper is a simplest way to crop image to any shapes you like. Example To run the example project, clone the repo, and run pod in

Mohammad Zaid Pathan 219 Dec 17, 2022
AZS - There are two frameworks in the pod file, you need to install them to work with the project

AZS There are two frameworks in the pod file, you need to install them to work w

Nikita12G 0 Jan 14, 2022
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.

ATGMediaBrowser ATGMediaBrowser is an image slide-show viewer that supports multiple predefined transition styles, and also allows the client to defin

null 200 Dec 19, 2022
SwiftUI project to show ActivityIndicator above Image while loading

ImageWithActivityIndicatorDemo SwiftUI project to show ActivityIndicator above Image while loading ImageWithActivityIndicatorDemo is a demo app that s

Ali Adam 4 May 27, 2021