Skip to content
Snippets Groups Projects
image.php 899 B
Newer Older
Georg Ehrke's avatar
Georg Ehrke committed
<?php
/**
 * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
Georg Ehrke's avatar
Georg Ehrke committed
 * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
Georg Ehrke's avatar
Georg Ehrke committed
 * 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
namespace OC\Preview;

Georg Ehrke's avatar
Georg Ehrke committed
class Image extends Provider {
	public function getMimeType() {
		return '/image\/(?!tiff$)(?!svg.*).*/';
Georg Ehrke's avatar
Georg Ehrke committed
	}
Georg Ehrke's avatar
Georg Ehrke committed

	public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
Georg Ehrke's avatar
Georg Ehrke committed
		//get fileinfo
Georg Ehrke's avatar
Georg Ehrke committed
		$fileInfo = $fileview->getFileInfo($path);
		if(!$fileInfo) {
			return false;
		}
Georg Ehrke's avatar
Georg Ehrke committed

		$image = new \OC_Image();
Georg Ehrke's avatar
Georg Ehrke committed
		if($fileInfo['encrypted'] === true) {
			$fileName = $fileview->toTmpFile($path);
		} else {
			$fileName = $fileview->getLocalFile($path);
Georg Ehrke's avatar
Georg Ehrke committed
		}
		$image->loadFromFile($fileName);
Georg Ehrke's avatar
Georg Ehrke committed

Georg Ehrke's avatar
Georg Ehrke committed
		return $image->valid() ? $image : false;
Georg Ehrke's avatar
Georg Ehrke committed
	}
\OC\Preview::registerProvider('OC\Preview\Image');