You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IPreview.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. /**
  28. * Public interface of ownCloud for apps to use.
  29. * Preview interface
  30. *
  31. */
  32. // use OCP namespace for all classes that are considered public.
  33. // This means that they should be used by apps instead of the internal ownCloud classes
  34. namespace OCP;
  35. use OCP\Files\File;
  36. use OCP\Files\NotFoundException;
  37. use OCP\Files\SimpleFS\ISimpleFile;
  38. /**
  39. * This class provides functions to render and show thumbnails and previews of files
  40. * @since 6.0.0
  41. */
  42. interface IPreview {
  43. /**
  44. * @since 9.2.0
  45. * @deprecated 22.0.0
  46. */
  47. public const EVENT = self::class . ':' . 'PreviewRequested';
  48. public const MODE_FILL = 'fill';
  49. public const MODE_COVER = 'cover';
  50. /**
  51. * In order to improve lazy loading a closure can be registered which will be
  52. * called in case preview providers are actually requested
  53. *
  54. * $callable has to return an instance of \OCP\Preview\IProvider
  55. *
  56. * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
  57. * @param \Closure $callable
  58. * @return void
  59. * @since 8.1.0
  60. */
  61. public function registerProvider($mimeTypeRegex, \Closure $callable);
  62. /**
  63. * Get all providers
  64. * @return array
  65. * @since 8.1.0
  66. */
  67. public function getProviders();
  68. /**
  69. * Does the manager have any providers
  70. * @return bool
  71. * @since 8.1.0
  72. */
  73. public function hasProviders();
  74. /**
  75. * Returns a preview of a file
  76. *
  77. * The cache is searched first and if nothing usable was found then a preview is
  78. * generated by one of the providers
  79. *
  80. * @param File $file
  81. * @param int $width
  82. * @param int $height
  83. * @param bool $crop
  84. * @param string $mode
  85. * @param string $mimeType To force a given mimetype for the file (files_versions needs this)
  86. * @return ISimpleFile
  87. * @throws NotFoundException
  88. * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
  89. * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
  90. */
  91. public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null);
  92. /**
  93. * Returns true if the passed mime type is supported
  94. * @param string $mimeType
  95. * @return boolean
  96. * @since 6.0.0
  97. */
  98. public function isMimeSupported($mimeType = '*');
  99. /**
  100. * Check if a preview can be generated for a file
  101. *
  102. * @param \OCP\Files\FileInfo $file
  103. * @return bool
  104. * @since 8.0.0
  105. */
  106. public function isAvailable(\OCP\Files\FileInfo $file);
  107. /**
  108. * Generates previews of a file
  109. *
  110. * @param File $file
  111. * @param array $specifications
  112. * @param string $mimeType
  113. * @return ISimpleFile the last preview that was generated
  114. * @throws NotFoundException
  115. * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
  116. * @since 19.0.0
  117. */
  118. public function generatePreviews(File $file, array $specifications, $mimeType = null);
  119. }