Skip to content

Commit

Permalink
Cleaned code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Oct 28, 2018
1 parent 149b81c commit a758f05
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
37 changes: 18 additions & 19 deletions libraries/UniversalViewer/Controller/Action/Helper/TileServer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Copyright 2015-2017 Daniel Berthereau
* Copyright 2015-2018 Daniel Berthereau
*
* This software is governed by the CeCILL license under French law and abiding
* by the rules of distribution of free software. You can use, modify and/or
Expand Down Expand Up @@ -297,8 +297,9 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
// In IIIF, levels start at the tile size.
$numLevels -= (int) log($cellSize, 2);
$squaleFactors = $this->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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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];
}

Expand All @@ -477,24 +476,24 @@ 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,
'height' => $height,
);
}
} 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,
];
);
}
}
3 changes: 3 additions & 0 deletions libraries/UniversalViewer/ImageServer/ImageMagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a758f05

Please sign in to comment.