image.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * @author Georg Ehrke <georg@owncloud.com>
  4. * @author Olivier Paroz <owncloud@interfasys.ch>
  5. * @author Joas Schilling <nickvergessen@owncloud.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. * @author Thomas Tanghus <thomas@tanghus.net>
  9. *
  10. * @copyright Copyright (c) 2015, ownCloud, Inc.
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\Preview;
  27. abstract class Image extends Provider {
  28. /**
  29. * {@inheritDoc}
  30. */
  31. public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
  32. //get fileinfo
  33. $fileInfo = $fileview->getFileInfo($path);
  34. if(!$fileInfo) {
  35. return false;
  36. }
  37. $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50);
  38. $size = $fileInfo->getSize();
  39. if ($maxSizeForImages !== -1 && $size > ($maxSizeForImages * 1024 * 1024)) {
  40. return false;
  41. }
  42. $image = new \OC_Image();
  43. if($fileInfo['encrypted'] === true) {
  44. $fileName = $fileview->toTmpFile($path);
  45. } else {
  46. $fileName = $fileview->getLocalFile($path);
  47. }
  48. $image->loadFromFile($fileName);
  49. $image->fixOrientation();
  50. return $image->valid() ? $image : false;
  51. }
  52. }