-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8cc69e
commit 60510a9
Showing
3 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,66 @@ | ||
**THIS PACKAGE IS STILL IN DEVELOPMENT** | ||
|
||
# Image IIIF | ||
|
||
add route patters for parameters | ||
Package implements the [IIIF Image API 2.1](http://iiif.io/api/image/2.1/). The package is unopinionated about implementation and many `MUST` features are not included. It is a bring your own framework solution for PHP. Regex is provided within the config for validation of image request parameters. | ||
|
||
Supports all Image Request Parameters: | ||
- Region (full || square || x,y,w,h || pct:x,y,w,h) | ||
- Size (full || max || w, || ,h || pct:n || w,h || !w,h) | ||
- Rotation (n || !n) | ||
- Quality (color || gray || default) | ||
- Format (jpg || png || gif || webp) | ||
|
||
Supports the `info.json` response for a indentifier. | ||
|
||
Currently only tested with 'GD' Libray. If utilizing 'Imagick' more config options may become available. | ||
|
||
Todo: | ||
- support more formats (tif, pdf) | ||
- figure out how to handle bitonal 1-bit images | ||
- utilize [php-vips](https:/jcupitt/php-vips) | ||
- setup demo / documentation site | ||
- Laravel and Slim demo applications | ||
|
||
|
||
#### Laravel image route example: | ||
|
||
```php | ||
Route::get('iiif/{identifier}/{region}/{size}/{rotation}/{quality}.{format}', | ||
function (Request $request) { | ||
$parameters = $request->route()->parameters(); | ||
|
||
$file = storage_path('app/images/'.$parameters['identifier']); | ||
|
||
$factory = new \Conlect\ImageIIIF\ImageFactory; | ||
|
||
$file = $factory()->load($file) | ||
->withParameters($parameters) | ||
->stream(); | ||
|
||
$response = \Response::make($file); | ||
|
||
$response->header('Content-Type', config("iiif.mime.{$parameters['format']}")); | ||
|
||
return $response; | ||
} | ||
); | ||
|
||
``` | ||
|
||
#### Laravel info route example: | ||
|
||
```php | ||
Route::get('iiif/{identifier}/info.json', | ||
function (Request $request) { | ||
$file = storage_path('app/images/'.$request->identifier); | ||
|
||
$factory = new \Conlect\ImageIIIF\ImageFactory; | ||
|
||
## License | ||
$info = $factory()->load($file) | ||
->info($request->identifier); | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
return $info; | ||
} | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters