Skip to content

Instantly share code, notes, and snippets.

@Tobias-pwnr
Tobias-pwnr / collect_images_with_text.rb
Created October 23, 2024 11:19
collect all images that contains 'money forward' with OCR tool, inside app/assets directory and all of its sub directory
#Install Tesseract: Install Tesseract OCR on your system. On macOS, you can use Homebrew:
#brew install tesseract
#Create a Ruby script: Create a Ruby script to scan images in the app/assets directory and use Tesseract to check for the text "money forward".
#Run the script: Execute the Ruby script to find all images containing the text "money forward":
# ruby collect_images_with_text.rb
require 'find'
require 'open3'
def image_contains_text?(image_path, text)
stdout, _stderr, _status = Open3.capture3("tesseract #{image_path} stdout")