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.

iimage.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Olivier Paroz <github@oparoz.com>
  6. *
  7. * @copyright Copyright (c) 2015, ownCloud, Inc.
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP;
  24. /**
  25. * Class for basic image manipulation
  26. * @since 8.1.0
  27. */
  28. interface IImage {
  29. /**
  30. * Determine whether the object contains an image resource.
  31. *
  32. * @return bool
  33. * @since 8.1.0
  34. */
  35. public function valid();
  36. /**
  37. * Returns the MIME type of the image or an empty string if no image is loaded.
  38. *
  39. * @return string
  40. * @since 8.1.0
  41. */
  42. public function mimeType();
  43. /**
  44. * Returns the width of the image or -1 if no image is loaded.
  45. *
  46. * @return int
  47. * @since 8.1.0
  48. */
  49. public function width();
  50. /**
  51. * Returns the height of the image or -1 if no image is loaded.
  52. *
  53. * @return int
  54. * @since 8.1.0
  55. */
  56. public function height();
  57. /**
  58. * Returns the width when the image orientation is top-left.
  59. *
  60. * @return int
  61. * @since 8.1.0
  62. */
  63. public function widthTopLeft();
  64. /**
  65. * Returns the height when the image orientation is top-left.
  66. *
  67. * @return int
  68. * @since 8.1.0
  69. */
  70. public function heightTopLeft();
  71. /**
  72. * Outputs the image.
  73. *
  74. * @param string $mimeType
  75. * @return bool
  76. * @since 8.1.0
  77. */
  78. public function show($mimeType = null);
  79. /**
  80. * Saves the image.
  81. *
  82. * @param string $filePath
  83. * @param string $mimeType
  84. * @return bool
  85. * @since 8.1.0
  86. */
  87. public function save($filePath = null, $mimeType = null);
  88. /**
  89. * @return resource Returns the image resource in any.
  90. * @since 8.1.0
  91. */
  92. public function resource();
  93. /**
  94. * @return string Returns the raw image data.
  95. * @since 8.1.0
  96. */
  97. public function data();
  98. /**
  99. * (I'm open for suggestions on better method name ;)
  100. * Get the orientation based on EXIF data.
  101. *
  102. * @return int The orientation or -1 if no EXIF data is available.
  103. * @since 8.1.0
  104. */
  105. public function getOrientation();
  106. /**
  107. * (I'm open for suggestions on better method name ;)
  108. * Fixes orientation based on EXIF data.
  109. *
  110. * @return bool
  111. * @since 8.1.0
  112. */
  113. public function fixOrientation();
  114. /**
  115. * Resizes the image preserving ratio.
  116. *
  117. * @param integer $maxSize The maximum size of either the width or height.
  118. * @return bool
  119. * @since 8.1.0
  120. */
  121. public function resize($maxSize);
  122. /**
  123. * @param int $width
  124. * @param int $height
  125. * @return bool
  126. * @since 8.1.0
  127. */
  128. public function preciseResize($width, $height);
  129. /**
  130. * Crops the image to the middle square. If the image is already square it just returns.
  131. *
  132. * @param int $size maximum size for the result (optional)
  133. * @return bool for success or failure
  134. * @since 8.1.0
  135. */
  136. public function centerCrop($size = 0);
  137. /**
  138. * Crops the image from point $x$y with dimension $wx$h.
  139. *
  140. * @param int $x Horizontal position
  141. * @param int $y Vertical position
  142. * @param int $w Width
  143. * @param int $h Height
  144. * @return bool for success or failure
  145. * @since 8.1.0
  146. */
  147. public function crop($x, $y, $w, $h);
  148. /**
  149. * Resizes the image to fit within a boundary while preserving ratio.
  150. *
  151. * @param integer $maxWidth
  152. * @param integer $maxHeight
  153. * @return bool
  154. * @since 8.1.0
  155. */
  156. public function fitIn($maxWidth, $maxHeight);
  157. /**
  158. * Shrinks the image to fit within a boundary while preserving ratio.
  159. *
  160. * @param integer $maxWidth
  161. * @param integer $maxHeight
  162. * @return bool
  163. * @since 8.1.0
  164. */
  165. public function scaleDownToFit($maxWidth, $maxHeight);
  166. }