|
|
@ -12,6 +12,7 @@ use Drupal\Core\Config\ImmutableConfig; |
|
|
|
use Drupal\Core\File\FileSystem; |
|
|
|
use Drupal\Core\File\FileSystem; |
|
|
|
use GuzzleHttp\Client; |
|
|
|
use GuzzleHttp\Client; |
|
|
|
use GuzzleHttp\Exception\ClientException; |
|
|
|
use GuzzleHttp\Exception\ClientException; |
|
|
|
|
|
|
|
use GuzzleHttp\Exception\ConnectException; |
|
|
|
use GuzzleHttp\Exception\ServerException; |
|
|
|
use GuzzleHttp\Exception\ServerException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -190,28 +191,25 @@ class IIIFManifest extends StylePluginBase { |
|
|
|
$width = $resource['width']; |
|
|
|
$width = $resource['width']; |
|
|
|
$height = $resource['height']; |
|
|
|
$height = $resource['height']; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ClientException $e) { |
|
|
|
catch (ClientException | ServerException | ConnectException $e) { |
|
|
|
} |
|
|
|
// If we couldn't get the info.json from IIIF |
|
|
|
catch (ServerException $e) { |
|
|
|
// try seeing if we can get it from Drupal. |
|
|
|
} |
|
|
|
if (empty($width) || empty($height)) { |
|
|
|
|
|
|
|
// Get the image properties so we know the image width/height. |
|
|
|
// If we couldn't get the info.json from IIIF |
|
|
|
$properties = $image->getProperties(); |
|
|
|
// try seeing if we can get it from Drupal. |
|
|
|
$width = isset($properties['width']) ? $properties['width'] : 0; |
|
|
|
if (empty($width) || empty($height)) { |
|
|
|
$height = isset($properties['height']) ? $properties['height'] : 0; |
|
|
|
// Get the image properties so we know the image width/height. |
|
|
|
|
|
|
|
$properties = $image->getProperties(); |
|
|
|
// If this is a TIFF AND we don't know the width/height |
|
|
|
$width = isset($properties['width']) ? $properties['width'] : 0; |
|
|
|
// see if we can get the image size via PHP's core function. |
|
|
|
$height = isset($properties['height']) ? $properties['height'] : 0; |
|
|
|
if ($mime_type === 'image/tiff' && !$width || !$height) { |
|
|
|
|
|
|
|
$uri = $image->entity->getFileUri(); |
|
|
|
// If this is a TIFF AND we don't know the width/height |
|
|
|
$path = $this->fileSystem->realpath($uri); |
|
|
|
// see if we can get the image size via PHP's core function. |
|
|
|
$image_size = getimagesize($path); |
|
|
|
if ($mime_type === 'image/tiff' && !$width || !$height) { |
|
|
|
if ($image_size) { |
|
|
|
$uri = $image->entity->getFileUri(); |
|
|
|
$width = $image_size[0]; |
|
|
|
$path = $this->fileSystem->realpath($uri); |
|
|
|
$height = $image_size[1]; |
|
|
|
$image_size = getimagesize($path); |
|
|
|
} |
|
|
|
if ($image_size) { |
|
|
|
|
|
|
|
$width = $image_size[0]; |
|
|
|
|
|
|
|
$height = $image_size[1]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|