Skip to content

Commit

Permalink
Merge pull request #2 from conlect/dev
Browse files Browse the repository at this point in the history
update config loading
  • Loading branch information
jeremytubbs authored Nov 18, 2018
2 parents 590f434 + 86c3d0a commit dabb7d7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": "^7.1",
"hassankhan/config": "^1.0",
"hassankhan/config": "^2.0",
"intervention/image": "^2.4"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion config/iiif.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'driver' => 'gd', //imagick

'base_url' => 'http://packages.test',
'base_url' => 'http://iiif.test',

'prefix' => 'iiif',

Expand Down
15 changes: 8 additions & 7 deletions src/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Conlect\ImageIIIF;

use Noodlehaus\Config;
use Noodlehaus\Parser\Json;
use Intervention\Image\ImageManager;

class ImageFactory
Expand All @@ -14,27 +15,28 @@ class ImageFactory
*/
protected $driver = 'gd';

protected $config;

public function __invoke(array $config = null)
{
public function __invoke(array $config = null)
{
if (is_null($config)) {
$config = new Config(__DIR__ . '/../config');
$config = new Config(__DIR__ . '/../config');
} else {
$config = new Config($config);
$config = new Config(json_encode($config), new Json, true);
}

$manager = $this->getImageManager($config['driver']);

return new ImageIIIF($manager, $config);
}
}


/**
*
* @return ImageManager
*/
public function getImageManager($driver = null)
{
{
if (is_null($driver)) {
$driver = $this->driver;
}
Expand All @@ -45,5 +47,4 @@ public function getImageManager($driver = null)
]
);
}

}
12 changes: 6 additions & 6 deletions src/ImageIIIF.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(ImageManager $manager, Config $config = null)
}

public function load($file)
{
{
$this->image = $this->manager->make($file);

return $this;
Expand Down Expand Up @@ -55,20 +55,20 @@ public function info($identifier)
{
return [
'@context' => 'http://iiif.io/api/image/2/context.json',
'@id' => $this->config->get('base_url') . '/' . $this->config->get('prefix') . '/' . $identifier,
'@id' => $this->config['base_url'] . '/' . $this->config['prefix'] . '/' . $identifier,
'protocol' => 'http://iiif.io/api/image',
'height' => $this->image->height(),
'width' => $this->image->width(),
'profile' => [
'http://iiif.io/api/image/2/level2.json', [
'supports' => config('iiif.supports'),
'qualities' => config('iiif.qualities'),
'formats' => config('iiif.formats')
'supports' => $this->config['supports'],
'qualities' => $this->config['qualities'],
'formats' => $this->config['formats']
]
],
'tiles'=> [
[
'width' => $this->config->get('tile_width'),
'width' => $this->config['tile_width'],
'scaleFactors' => $this->getScaleFactors(),
]
],
Expand Down

0 comments on commit dabb7d7

Please sign in to comment.