Actions icon indicating copy to clipboard operation
Actions copied to clipboard

Action proposal: for image/document, detect and extract any Barcode type data supported in Vision Framework

Open workflowsguy opened this issue 3 years ago • 6 comments

Description

For automated document processing, it would be great to have actions that

  1. detect if/which kinds of barcodes a pdf or image file contains
  2. extracts data for selected types of barcodes

Apple's Vision framework already supports various types of barcodes like:

  • aztec
  • code128
  • code39
  • code39Mod43
  • code93
  • dataMatrix
  • ean13
  • ean8
  • interleaved2of5
  • itf14
  • pdf417
  • qr
  • upce

but there seems to be no easy way to process them with Automator/Shortcut actions, AppleScript or other scripting languages.

workflowsguy avatar Oct 13 '22 10:10 workflowsguy

What would you like the result to look like?

I'm thinking a list of:

  • value: something
  • type: qr

The Vision framework uses the term "symbology" instead of "type", but I think "type" is more understandable for users.

sindresorhus avatar Oct 29 '22 14:10 sindresorhus

Proposed action name: Get Barcodes in Image

sindresorhus avatar Oct 29 '22 14:10 sindresorhus

Note to self: https://developer.apple.com/documentation/vision/vndetectbarcodesrequest

sindresorhus avatar Oct 29 '22 14:10 sindresorhus

What would you like the result to look like?

I'm thinking a list of:

* **value:** something

* **type:** qr

As I understand the implementation of Shortcuts' data structures, the result would be a dictionary of "key:barcode value", "value:barcode type" pairs.

I have seen that Shortcuts' dictionaries allow multiple keys with the same name (which is not allowed in other programming language implementations of this data type), but maybe this can be checked and prevented in the Action's source code. Then, even if the same barcode value appears multiple times in the document, in the dictionary it would still appear only once in the result list. I think, typically a user would be interested primarly in the keys (but they could also get the barcode type if they wanted).

My use case for a Shortcut that detects document data:

  • for each value in the "detected barcode result dict", test against a specific data type ("is ISBN"? "is EAN"? "is encoded payment information?"
  • for each matched identifier/group of identifiers, attach a "IDENTIFIER:VALUE" tag to the original file (e.g. "ISBN:9781592535217" or "AMOUNT:123.45" and "DUE:2022-11-02"

The Vision framework uses the term "symbology" instead of "type", but I think "type" is more understandable for users.

I agree.

workflowsguy avatar Nov 02 '22 17:11 workflowsguy

As I understand the implementation of Shortcuts' data structures, the result would be a dictionary of "key:barcode value", "value:barcode type" pairs.

No, the result would be a list (multiple) of this:

{
	"type": "qr",
	"value": "…"
}

sindresorhus avatar Nov 02 '22 18:11 sindresorhus

Thanks for the clarification.

workflowsguy avatar Nov 05 '22 10:11 workflowsguy