previewmanager.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. * @brief return a preview of a file
  15. * @param string $file The path to the file where you want a thumbnail from
  16. * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
  17. * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
  18. * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
  19. * @return \OCP\Image
  20. */
  21. function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false)
  22. {
  23. $preview = new \OC\Preview('', '/', $file, $maxX, $maxY, $scaleUp);
  24. return $preview->getPreview();
  25. }
  26. /**
  27. * @brief returns true if the passed mime type is supported
  28. * @param string $mimeType
  29. * @return boolean
  30. */
  31. function isMimeSupported($mimeType = '*')
  32. {
  33. return \OC\Preview::isMimeSupported($mimeType);
  34. }
  35. }