previewmanager.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Thomas Müller thomas.mueller@tmit.eu
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. *
  8. */
  9. namespace OC;
  10. use OCP\image;
  11. use OCP\IPreview;
  12. class PreviewManager implements IPreview {
  13. /**
  14. * return a preview of a file
  15. *
  16. * @param string $file The path to the file where you want a thumbnail from
  17. * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
  18. * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
  19. * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
  20. * @return \OCP\Image
  21. */
  22. function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false) {
  23. $preview = new \OC\Preview('', '/', $file, $maxX, $maxY, $scaleUp);
  24. return $preview->getPreview();
  25. }
  26. /**
  27. * returns true if the passed mime type is supported
  28. *
  29. * @param string $mimeType
  30. * @return boolean
  31. */
  32. function isMimeSupported($mimeType = '*') {
  33. return \OC\Preview::isMimeSupported($mimeType);
  34. }
  35. /**
  36. * Check if a preview can be generated for a file
  37. *
  38. * @param \OC\Files\FileInfo $file
  39. * @return bool
  40. */
  41. function isAvailable($file) {
  42. return \OC\Preview::isAvailable($file);
  43. }
  44. }