Skip to content
/ imgrep Public

CLI tool that allows searching for text in images

License

Notifications You must be signed in to change notification settings

emcassi/imgrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgrep

Introduction

imgrep is a command-line tool that allows users to search for a given pattern in images. It uses optical character recognition (OCR) to extract text from images and performs pattern matching on the extracted text.

The tool is designed to be flexible and configurable, supporting various options like case-insensitive matching, ignoring punctuation, inverting the match, and providing a context around the matched text.

Features

  • Perform text pattern matching in images.
  • Configurable flags for case-insensitive and punctuation-ignoring matching.
  • Invert match to display lines that do not match the pattern.
  • Display context around the matched text with padding.

Dependencies

Installation

To use imgrep, you need to have Go installed on your system.

git clone https://github.com/emcassi/imgrep.git
cd imgrep
go build -o imgrep

Usage

To search for a pattern in an image, use the following command:

./imgrep [flags] pattern file.png [file2.png ...]

Flags

  • -ic: Ignore case when matching.
  • -ip: Ignore punctuation when matching.
  • -x: Invert match (display lines that do not match the pattern).
  • -p: Padding (characters) for displaying matched text.

Arguments

  • Arg 1 : pattern - accepts regex
  • Arg 2+ : file names

Examples:

./imgrep -ic -ip -p 10 hello image1.png
./imgrep -ic hello imgs/image.png # image in a subfolder
./imgrep -ic hello image1.png image2.png # input for multiple images
./imgrep -p 50 '(?i)john' image1.png # supports go style regex statements
./imgrep -x error image2.png # invert - exclude the pattern in the results

Roadmap

  • Add ocr functionality
  • Add argument parsing
  • Be able to grep a single image
  • Be able to grep multiple images
  • Be able to pass directories of images
  • Add concurrency support
  • Further Testing
  • Add documentation

Contributing

Contributions are welcome! If you want to contribute to imgrep, please follow these steps:

  • Read the Contributing guidelines
  • Fork the repository and create your branch from main.
  • Make sure your code follows the Go coding style.
  • Run tests to ensure your changes don't break existing functionality.
  • Open a pull request with a clear description of your changes.

License

This project is licensed under the MIT License.

Acknowledgements

gosseract: A Go library for OCR.

Contact

For any questions or suggestions, feel free to get in touch:

GitHub: emcassi

Email: [email protected]

About

CLI tool that allows searching for text in images

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages