2014-10-04 15:50:12 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-02-26 10:37:37 +00:00
|
|
|
* Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
2014-10-04 15:50:12 +00:00
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2014-11-28 08:25:40 +00:00
|
|
|
namespace OC\Preview;
|
2014-10-04 15:50:12 +00:00
|
|
|
|
2014-11-28 08:25:40 +00:00
|
|
|
abstract class Bitmap extends Provider {
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
|
|
|
$tmpPath = $fileview->toTmpFile($path);
|
|
|
|
|
|
|
|
//create imagick object from bitmap or vector file
|
|
|
|
try {
|
|
|
|
// Layer 0 contains either the bitmap or
|
|
|
|
// a flat representation of all vector layers
|
|
|
|
$bp = new \Imagick($tmpPath . '[0]');
|
|
|
|
|
|
|
|
$bp->setImageFormat('png');
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
|
|
|
return false;
|
2014-10-04 15:50:12 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 08:25:40 +00:00
|
|
|
unlink($tmpPath);
|
2014-11-27 18:40:23 +00:00
|
|
|
|
2014-11-28 08:25:40 +00:00
|
|
|
//new bitmap image object
|
|
|
|
$image = new \OC_Image($bp);
|
|
|
|
//check if image object is valid
|
|
|
|
return $image->valid() ? $image : false;
|
2014-10-04 15:50:12 +00:00
|
|
|
}
|
2014-11-28 08:25:40 +00:00
|
|
|
}
|