ipreview.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Robin Appelman <icewind@owncloud.com>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @copyright Copyright (c) 2015, ownCloud, Inc.
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. /**
  25. * Public interface of ownCloud for apps to use.
  26. * Preview interface
  27. *
  28. */
  29. // use OCP namespace for all classes that are considered public.
  30. // This means that they should be used by apps instead of the internal ownCloud classes
  31. namespace OCP;
  32. /**
  33. * This class provides functions to render and show thumbnails and previews of files
  34. */
  35. interface IPreview {
  36. /**
  37. * In order to improve lazy loading a closure can be registered which will be
  38. * called in case preview providers are actually requested
  39. *
  40. * $callable has to return an instance of \OCP\Preview\IProvider
  41. *
  42. * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
  43. * @param \Closure $callable
  44. * @return void
  45. */
  46. public function registerProvider($mimeTypeRegex, \Closure $callable);
  47. /**
  48. * Get all providers
  49. * @return array
  50. */
  51. public function getProviders();
  52. /**
  53. * Does the manager have any providers
  54. * @return bool
  55. */
  56. public function hasProviders();
  57. /**
  58. * Return a preview of a file
  59. * @param string $file The path to the file where you want a thumbnail from
  60. * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
  61. * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
  62. * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
  63. * @return \OCP\IImage
  64. */
  65. public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false);
  66. /**
  67. * Returns true if the passed mime type is supported
  68. * @param string $mimeType
  69. * @return boolean
  70. */
  71. public function isMimeSupported($mimeType = '*');
  72. /**
  73. * Check if a preview can be generated for a file
  74. *
  75. * @param \OCP\Files\FileInfo $file
  76. * @return bool
  77. */
  78. public function isAvailable(\OCP\Files\FileInfo $file);
  79. }