Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Last active May 6, 2023 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elijahmanor/e0fb0377d77b15cb8f3ac6e2b6cafa13 to your computer and use it in GitHub Desktop.
Save elijahmanor/e0fb0377d77b15cb8f3ac6e2b6cafa13 to your computer and use it in GitHub Desktop.
OCR from macOS Terminal

I was reviewing a PR and there was a screenshot of the terminal that had output I wanted in text form.

Terminal Screenshot

So, I installed an OCR tool locally (called tesseract) and converted the PNG into TEXT.

# Install the OCR tool
brew install tesseract tesseract-lang

# Convert the PNG to TEXT
tesseract packages.png packages

# Output the contents
cat packages.txt
? Choose which packages to update. @storybook/addon-a11y@6.4.22, @storybook/addon-actions@6.4.22, @storybook/addon-docs@6.4.22, @storybook/addon-viewport@6.4.22, @storybook/react@6.4.22, @wojtekmaj/enzyme-adapter-react-17@0.6.7, @wojtekmaj/enzyme-adapter-r
eact-17@0.6.7, chai@4.3.6, got@11.8.3, got@11.8.3, html-to-react@1.4.8, Less@4.1.2, less@4.1.2, mock-socket@9.1.2, moment@2.29.3, moment-timezone@0.5.34, moment-timezone@0.5.34, nodemon@2.0.15, nodemon@2.0.15, plop@2.7.6, postcss@7.0.39, react-onclickoutsi
de@6.12.1, react-router-dom@5.3.1, react-router-dom@5.3.1, shelljs@0.8.5, shelljs@0.8.5, source-map-support@0.5.21, source-map-support@0.5.21, styled-components@5.3.5, svg-sprite@1.5.4, webpack-dev-server@3.11.3, cookie-parser@1.4.6, express@4.17.3, expres
sQ4.17.3, html-to-react@1.4.8, moment@2.29.3, moment@2.29.3, moment@2.29.3, moment@2.29.3, moment@2.29.3, moment@2.29.3, moment@2.29.3, moment@2.29.3, normalizr@3.6.2, papaparse@5.3.2, react-onclickoutside@6.12.1, react-onclickoutside@6.12.1, react-router-
dom@5.3.1, react-router-dom@5.3.1, redux@4.1.2, slugify@1.6.5, slugify@1.6.5, styled-components@5.3.5, styled-components@5.3.5
@mbaneshi
Copy link

mbaneshi commented May 6, 2023

I alias it p2t,(picture to text) , so no more forgotten command
alias p2t='tesseract '

@elijahmanor
Copy link
Author

@mbaneshi smart! well done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment