Skip to content

Commit

Permalink
update AlfredOCR
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlings committed Mar 3, 2023
1 parent 3e68feb commit dd78126
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ You can define fallback dictionaries for lookups, set the font size of the previ
![](assets/images/dict-dark.jpg)

## 1.6. AlfredOCR
[![](https://img.shields.io/badge/download-v1.0.0-informational)](https://github.com/zeitlings/alfred-workflows/releases/tag/v1.0.0-ocr)
[![](https://img.shields.io/badge/download-v1.0.1-informational)](https://github.com/zeitlings/alfred-workflows/releases/tag/v1.0.1-ocr)
[![](https://img.shields.io/static/v1?message=AlfredOCR.swift&color=F05138&logo=Swift&logoColor=FFFFFF&label=Code)](/assets/code/AlfredOCR.swift)

<table>
Expand All @@ -195,7 +195,7 @@ You can define fallback dictionaries for lookups, set the font size of the previ
<img src="assets/icons/ocr.png">
</td>
<td>
Optical Character Recognition Workflow. Take a snapshot and copy the recognized text to the clipboard. No external dependencies are required to perform the OCR.
The workflow allows you to copy text from images using optical character recognition. Take a snapshot with your mouse or trackpad and the recognized text is automatically copied to the clipboard. No external dependencies are required to perform the OCR.
</td>
</tr>
</table>
Expand Down
6 changes: 5 additions & 1 deletion assets/code/AlfredOCR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ extension AlfredOCR {
guard let observations = request.results as? [VNRecognizedTextObservation] else {
return
}
let pasteBoard: NSPasteboard = .general
let recognized: [String] = observations.compactMap({ $0.topCandidates(1).first?.string })
let merged: String = recognized.joined(separator: "\n")
try? fileManager.removeItem(atPath: PATH)
print(recognized.joined(separator: "\n"))
pasteBoard.clearContents()
pasteBoard.setString(merged, forType: .string)
print(merged)
Darwin.exit(EXIT_SUCCESS)
}

Expand Down
Binary file modified assets/icons/ocr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd78126

Please sign in to comment.