jfuentestgn/ocr-space
Composer 安装命令:
composer require jfuentestgn/ocr-space
包简介
Laravel OCR.space API Client
README 文档
README
Laravel (or just plain PHP) class for calling https://ocr.space/ free API
This package provides an independent implementation of an OCR.space API client for Laravel (or PHP) applications
OCR.API is a free/paid API for the OCR.space online service that converts images of text documents in text strings using OCR technologies
Requirements
- PHP >= 5.6.4
- A valid key from OCR API (registration needed)
Installation
To get OCR.space API just use the require command of composer or edit manually your composer.json, adding the require block (then you should run composer update):
$ composer require jfuentestgn/ocr-space
{
"require": {
"jfuentestgn/ocr-space": "dev-master"
}
}
After install the package, if you want to use it in a Laravel application, you should register the service provider. Add the OcrServiceProvider class to the list of providers in config/app.php:
'providers' => [ .... JFuentesTgn\OcrSpace\OcrServiceProvider::class, ... ]
If you want to use the Facade version of the service, you could add an alias in config/app.php:
'aliases' => [ .... 'OCR' => JFuentesTgn\OcrSpace\OcrFacade::class, ... ]
Configuration
This package requires an API key to work. First of all, register in the OCR API site to get a valid KEY
Publish vendor assets to get a local copy of the config file:
$ php artisan vendor:publish --provider=JFuentesTgn\\OcrSpace\\OcrServiceProvider
This will create a config/ocrspace.php file in your app. Edit this file and update the API key configuration property
Usage
In Laravel, you can use the OcrAPI class service as any other injected service. As an exemple:
use JFuentesTgn\OcrSpace\OcrAPI; class TestController extends Controller { public function processImage(Request $request, OcrAPI $ocr) { // You can use the $ocr instance to call OCR.space web service $response = $ocr->parseImageFile($imageFile); } }
If you prefer to use the facade interface, you can do just this:
$response = OCR::parseImageFile($imageFile);
Laravel is not a requirement for this package. If you need to use it outside a Laravel app, you can just create an instance of the API as with any other class:
$ocr = new OcrAPI($apiKey); $response = $ocr->parseImageFile($imageFile);
In this case you MUST pass your API key as a parameter to the constructor
The response (JFuentesTgn\OcrSpace\OcrResponse) object returned by the OcrAPI methods maps JSON response from OCR.space online service in an object oriented way.
This is an example of how to read the service response:
$image = 'snap_005.jpg'; $response = $ocr->parseImageFile($image); if ($response->length() == 1) { $text = $response->items(0)->text(); }
Credits
This package is maintained by Juan Fuentes
OCR.space is a service of a9t9 software GmbH. They are also in github
This package is an independent development that is in no way linked to a9t9 software. I want to acknowledge a9t9 for put this OCR service online
License
Laravel OCR.space API is licensed under The MIT License (MIT).
jfuentestgn/ocr-space 适用场景与选型建议
jfuentestgn/ocr-space 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.05k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2017 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「service」 「OCR」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jfuentestgn/ocr-space 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jfuentestgn/ocr-space 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jfuentestgn/ocr-space 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A fast and intuitive dependency injection container.
A PSR-7 compatible library for making CRUD API endpoints
Registry service.
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
Service auto install for Nette Framework
Structure for the Laravel Service-Repository Pattern
统计信息
- 总下载量: 43.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-19