janrop / highlight-text-in-image
Find and highlight Text in Images using Google Cloud Vision API
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 183
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
pkg:composer/janrop/highlight-text-in-image
Requires
- php: >=5.4.0
- ext-gd: *
- google/cloud-vision: ^0.3.0
Requires (Dev)
- phpunit/phpunit: ^6.1
This package is not auto-updated.
Last update: 2023-09-16 22:00:55 UTC
README
Lets you check for and highlight strings in images utilizing Googles Cloud Vision API
Installation
$ composer require janrop/highlight-text-in-image
Before using you need to download a Google Authentication Details .json file and reference it in the GOOGLE_APPLICATION_CREDENTIALS environment variable:
putenv('GOOGLE_APPLICATION_CREDENTIALS=./path_to/google_application_credentials.json');
Usage
use Janrop\TextInImageHighlighter;
$image = fopen(__DIR__ . '/Lorem_Ipsum_Helvetica.png', 'r'); $highlighter = new \Janrop\TextInImageHighlighter($image); # Check if String "Foo" exists in document. # If it does highlight it with a green border. # If not highlight all Blocks containing "Bar" with a red border. if($highlighter->find('Foo')->countMatches()){ $highlighter->highlight([0, 255, 0], 3); }else{ $highlighter->find('Bar', false) ->highlight([255, 0, 0], 3); } # Save image to jpeg imagejpeg($highlighter->getImage(), "annotated.jpg");