janrop / highlight-text-in-image
There is no license information available for the latest version (v1.0) of this package.
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.
v1.0
2017-06-23 09:34 UTC
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");