image.php 902 Bytes
Newer Older
Georg Ehrke's avatar
Georg Ehrke committed
1
2
3
<?php
/**
 * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
Georg Ehrke's avatar
Georg Ehrke committed
4
 * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
Georg Ehrke's avatar
Georg Ehrke committed
5
6
7
8
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
Georg Ehrke's avatar
Georg Ehrke committed
9
10
namespace OC\Preview;

Georg Ehrke's avatar
Georg Ehrke committed
11
class Image extends Provider {
12
13
14
	/**
	 * {@inheritDoc}
	 */
Georg Ehrke's avatar
Georg Ehrke committed
15
	public function getMimeType() {
16
		return '/image\/(?!tiff$)(?!svg.*).*/';
Georg Ehrke's avatar
Georg Ehrke committed
17
	}
Georg Ehrke's avatar
Georg Ehrke committed
18

19
20
21
	/**
	 * {@inheritDoc}
	 */
Georg Ehrke's avatar
Georg Ehrke committed
22
	public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
Georg Ehrke's avatar
Georg Ehrke committed
23
		//get fileinfo
Georg Ehrke's avatar
Georg Ehrke committed
24
25
26
27
		$fileInfo = $fileview->getFileInfo($path);
		if(!$fileInfo) {
			return false;
		}
Georg Ehrke's avatar
Georg Ehrke committed
28

29
		$image = new \OC_Image();
30

Georg Ehrke's avatar
Georg Ehrke committed
31
		if($fileInfo['encrypted'] === true) {
32
33
34
			$fileName = $fileview->toTmpFile($path);
		} else {
			$fileName = $fileview->getLocalFile($path);
Georg Ehrke's avatar
Georg Ehrke committed
35
		}
36
		$image->loadFromFile($fileName);
37
		$image->fixOrientation();
Georg Ehrke's avatar
Georg Ehrke committed
38

Georg Ehrke's avatar
Georg Ehrke committed
39
		return $image->valid() ? $image : false;
Georg Ehrke's avatar
Georg Ehrke committed
40
	}
41

Georg Ehrke's avatar
Georg Ehrke committed
42
}