1 | <?php |
||
5 | class ImageCropper extends ImageManipulator |
||
6 | { |
||
7 | /** |
||
8 | * @var resource |
||
9 | */ |
||
10 | protected $image; |
||
11 | |||
12 | /** |
||
13 | * @var resource |
||
14 | */ |
||
15 | protected $cropped; |
||
16 | |||
17 | /** |
||
18 | * Loads image from string |
||
19 | * |
||
20 | * @param string $imageData |
||
21 | */ |
||
22 | public function loadImageFromString($imageData) |
||
26 | |||
27 | /** |
||
28 | * Loads image from file |
||
29 | * |
||
30 | * @param string $filepath |
||
31 | */ |
||
32 | public function loadImageFromFile($filepath) |
||
36 | |||
37 | /** |
||
38 | * Crops image |
||
39 | * |
||
40 | * @param int $sourceX Source image top left X coordinate |
||
41 | * @param int $sourceY Source image top left Y coordinate |
||
42 | * @param int $sourceWidth Area width on source image |
||
43 | * @param int $sourceHeight Area height on source image |
||
44 | * @param int $targetWidth Area width on destination image |
||
45 | * @param int $targetHeight Area height on destination image |
||
46 | * |
||
47 | * @throws \LogicException |
||
48 | */ |
||
49 | public function crop($sourceX, $sourceY, $sourceWidth, $sourceHeight, $targetWidth, $targetHeight) |
||
79 | |||
80 | /** |
||
81 | * Returns image as string |
||
82 | * |
||
83 | * @param string $format |
||
84 | * |
||
85 | * @return string |
||
86 | * |
||
87 | * @throws \LogicException |
||
88 | */ |
||
89 | public function getCroppedImageAsString($format = self::FORMAT_PNG) |
||
97 | |||
98 | /** |
||
99 | * Saves image to a file |
||
100 | * |
||
101 | * @param string $filepath |
||
102 | * @param string $format |
||
103 | */ |
||
104 | public function saveCroppedImageToFile($filepath, $format = self::FORMAT_PNG) |
||
108 | } |