AdapterInterface.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Image\Adapter;
  7. /**
  8. * Interface \Magento\Framework\Image\Adapter\AdapterInterface
  9. *
  10. */
  11. interface AdapterInterface
  12. {
  13. /**
  14. * Adapter type
  15. */
  16. const ADAPTER_GD2 = 'GD2';
  17. const ADAPTER_IM = 'IMAGEMAGICK';
  18. /**
  19. * Returns rgba array of the specified pixel
  20. *
  21. * @param int $x
  22. * @param int $y
  23. * @return array
  24. */
  25. public function getColorAt($x, $y);
  26. /**
  27. * @see \Magento\Framework\Image\Adapter\AbstractAdapter::getImage
  28. * @return string
  29. */
  30. public function getImage();
  31. /**
  32. * Add watermark to image
  33. *
  34. * @param string $imagePath
  35. * @param int $positionX
  36. * @param int $positionY
  37. * @param int $opacity
  38. * @param bool $tile
  39. * @return void
  40. */
  41. public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = 30, $tile = false);
  42. /**
  43. * Reassign image dimensions
  44. *
  45. * @return void
  46. */
  47. public function refreshImageDimensions();
  48. /**
  49. * Checks required dependencies
  50. *
  51. * @return void
  52. * @throws \Exception If some of dependencies are missing
  53. */
  54. public function checkDependencies();
  55. /**
  56. * Create Image from string
  57. *
  58. * @param string $text
  59. * @param string $font
  60. * @return \Magento\Framework\Image\Adapter\AbstractAdapter
  61. */
  62. public function createPngFromString($text, $font = '');
  63. /**
  64. * Open image for processing
  65. *
  66. * @param string $filename
  67. * @return void
  68. */
  69. public function open($filename);
  70. /**
  71. * Change the image size
  72. *
  73. * @param null|int $frameWidth
  74. * @param null|int $frameHeight
  75. * @return void
  76. */
  77. public function resize($frameWidth = null, $frameHeight = null);
  78. /**
  79. * Crop image
  80. *
  81. * @param int $top
  82. * @param int $left
  83. * @param int $right
  84. * @param int $bottom
  85. * @return bool
  86. */
  87. public function crop($top = 0, $left = 0, $right = 0, $bottom = 0);
  88. /**
  89. * Save image to specific path.
  90. * If some folders of path does not exist they will be created
  91. *
  92. * @param null|string $destination
  93. * @param null|string $newName
  94. * @return void
  95. * @throws \Exception If destination path is not writable
  96. */
  97. public function save($destination = null, $newName = null);
  98. /**
  99. * Rotate image on specific angle
  100. *
  101. * @param int $angle
  102. * @return void
  103. */
  104. public function rotate($angle);
  105. }