images.php 889 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
  4. * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
  5. * This file is licensed under the Affero General Public License version 3 or
  6. * later.
  7. * See the COPYING-README file.
  8. */
  9. namespace OC\Preview;
  10. class Image extends Provider {
  11. public function getMimeType() {
  12. return '/image\/.*/';
  13. }
  14. public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
  15. //get fileinfo
  16. $fileInfo = $fileview->getFileInfo($path);
  17. if(!$fileInfo) {
  18. return false;
  19. }
  20. //check if file is encrypted
  21. if($fileInfo['encrypted'] === true) {
  22. $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r')));
  23. }else{
  24. $image = new \OC_Image();
  25. $image->loadFromFile($fileview->getLocalFile($path));
  26. }
  27. return $image->valid() ? $image : false;
  28. }
  29. }
  30. \OC\Preview::registerProvider('OC\Preview\Image');