From a758f059709906749103e1b23aa2a3e6d9620cca Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 29 Oct 2018 00:00:00 +0100 Subject: [PATCH] Cleaned code. --- controllers/ImageController.php | 2 +- controllers/MediaController.php | 2 +- .../Controller/Action/Helper/TileServer.php | 37 +++++++++---------- .../ImageServer/ImageMagick.php | 3 ++ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/controllers/ImageController.php b/controllers/ImageController.php index eb5d3a94..40273f35 100644 --- a/controllers/ImageController.php +++ b/controllers/ImageController.php @@ -44,7 +44,7 @@ public function badAction() /** * Send "info.json" for the current file. * - * @internal The info is managed by the ImageControler because it indicates + * The info is managed by the ImageControler because it indicates * capabilities of the IIIF server for the request of a file. */ public function infoAction() diff --git a/controllers/MediaController.php b/controllers/MediaController.php index 2e3f7d39..4e1e9966 100644 --- a/controllers/MediaController.php +++ b/controllers/MediaController.php @@ -42,7 +42,7 @@ public function badAction() /** * Send "info.json" for the current file. * - * @internal The info is managed by the MediaControler because it indicates + * The info is managed by the MediaControler because it indicates * capabilities of the IXIF server for the request of a file. */ public function infoAction() diff --git a/libraries/UniversalViewer/Controller/Action/Helper/TileServer.php b/libraries/UniversalViewer/Controller/Action/Helper/TileServer.php index 6d8e9b49..cd67f656 100644 --- a/libraries/UniversalViewer/Controller/Action/Helper/TileServer.php +++ b/libraries/UniversalViewer/Controller/Action/Helper/TileServer.php @@ -1,7 +1,7 @@ getScaleFactors($numLevels); - $maxSize = max($source['width'], $source['height']); - $total = (int) ceil($maxSize / $tileInfo['size']); + // TODO Find why maxSize and total were needed. + // $maxSize = max($source['width'], $source['height']); + // $total = (int) ceil($maxSize / $tileInfo['size']); // If level is set, count is not set and useless. $level = isset($level) ? $level : 0; $count = isset($count) ? $count : 0; @@ -397,7 +398,7 @@ protected function getScaleFactors($numLevels) /** * Return the tile group of a tile from level, position and size. * - * @link https://github.com/openlayers/ol3/blob/master/src/ol/source/zoomifysource.js + * @link https://github.com/openlayers/openlayers/blob/v4.0.0/src/ol/source/zoomify.js * * @param array $image * @param array $tile @@ -418,10 +419,10 @@ protected function getTileGroup($image, $tile) case 'default': $tileSize = $tile['size']; while ($image['width'] > $tileSize || $image['height'] > $tileSize) { - $tierSizeInTiles[] = [ + $tierSizeInTiles[] = array( ceil($image['width'] / $tileSize), ceil($image['height'] / $tileSize), - ]; + ); $tileSize += $tileSize; } break; @@ -430,10 +431,10 @@ protected function getTileGroup($image, $tile) $width = $image['width']; $height = $image['height']; while ($width > $tile['size'] || $height > $tile['size']) { - $tierSizeInTiles[] = [ + $tierSizeInTiles[] = array( ceil($width / $tile['size']), ceil($height / $tile['size']), - ]; + ); $width >>= 1; $height >>= 1; } @@ -443,15 +444,13 @@ protected function getTileGroup($image, $tile) return; } - $tierSizeInTiles[] = [1, 1]; + $tierSizeInTiles[] = array(1, 1); $tierSizeInTiles = array_reverse($tierSizeInTiles); - $resolutions = [1]; - $tileCountUpToTier = [0]; + $tileCountUpToTier = array(0); for ($i = 1, $ii = count($tierSizeInTiles); $i < $ii; $i++) { - $resolutions[] = 1 << $i; $tileCountUpToTier[] = - $tierSizeInTiles[$i - 1][0] * $tierSizeInTiles[$i - 1][1] + $tierSizeInTiles[$i - 1][0] * $tierSizeInTiles[$i - 1][1] + $tileCountUpToTier[$i - 1]; } @@ -477,7 +476,7 @@ protected function getWidthAndHeight($filepath) $tempname = tempnam(sys_get_temp_dir(), 'uv_'); $result = file_put_contents($tempname, $filepath); if ($result !== false) { - list($width, $height, $type, $attr) = getimagesize($filepath); + list($width, $height) = getimagesize($filepath); unlink($tempname); return array( 'width' => $width, @@ -485,16 +484,16 @@ protected function getWidthAndHeight($filepath) ); } } elseif (file_exists($filepath)) { - list($width, $height, $type, $attr) = getimagesize($filepath); - return [ + list($width, $height) = getimagesize($filepath); + return array( 'width' => $width, 'height' => $height, - ]; + ); } - return [ + return array( 'width' => null, 'height' => null, - ]; + ); } } diff --git a/libraries/UniversalViewer/ImageServer/ImageMagick.php b/libraries/UniversalViewer/ImageServer/ImageMagick.php index 1ffebd09..b145a625 100644 --- a/libraries/UniversalViewer/ImageServer/ImageMagick.php +++ b/libraries/UniversalViewer/ImageServer/ImageMagick.php @@ -203,6 +203,9 @@ public function transform(array $args = array()) escapeshellarg($this->_supportedFormats[$args['format']['feature']] . ':' . $destination) ); + $status = 0; + $output = ''; + $errors = array(); Omeka_File_Derivative_Strategy_ExternalImageMagick::executeCommand($command, $status, $output, $errors); $result = $status == 0;