ThumbnailService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getThumbnailSpecs() 0 11 2
1
<?php
2
/**
3
 * Nextcloud - Gallery
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Olivier Paroz <[email protected]>
9
 *
10
 * @copyright Olivier Paroz 2017
11
 */
12
13
namespace OCA\Gallery\Service;
14
15
/**
16
 * Deals with any thumbnail specific requests
17
 *
18
 * @package OCA\Gallery\Service
19
 */
20
class ThumbnailService {
21
22
	/**
23
	 * @var bool
24
	 */
25
	private $animatedPreview = false;
26
	/**
27
	 * @var bool
28
	 */
29
	private $base64Encode = true;
30
31
	/**
32
	 * Returns thumbnail specs
33
	 *
34
	 *    * Album thumbnails need to be 200x200 and some will be resized by the
35
	 *      browser to 200x100 or 100x100.
36
	 *    * Standard thumbnails are 400x200.
37
	 *
38
	 * @param bool $square
39
	 * @param double $scale
40
	 *
41
	 * @return array<double|boolean>
42
	 */
43
	public function getThumbnailSpecs($square, $scale) {
44
		$height = ceil(200 * $scale);
45
		if ($square) {
46
			$width = $height;
47
		} else {
48
			$width = 2 * $height;
49
		}
50
51
		$thumbnail = [$width, $height, !$square, $this->animatedPreview, $this->base64Encode];
52
53
		return $thumbnail;
54
	}
55
56
}
57