ipreview.php 2.8 KB

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