@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace Compolomus\Compomage; |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace Compolomus\Compomage\Interfaces; |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace Compolomus\Compomage; |
4 | 4 |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | return $this->prepareWatermark( |
111 | 111 | $watermark, |
112 | - (int)((($this->getWidth() - $watermark->getWidth()) / 2) * self::POSITIONS[strtoupper($position)]['x']) + self::POSITIONS[strtoupper($position)]['padX'], |
|
113 | - (int)((($this->getHeight() - $watermark->getHeight()) / 2) * self::POSITIONS[strtoupper($position)]['y']) + self::POSITIONS[strtoupper($position)]['padY'] |
|
112 | + (int) ((($this->getWidth() - $watermark->getWidth()) / 2) * self::POSITIONS[strtoupper($position)]['x']) + self::POSITIONS[strtoupper($position)]['padX'], |
|
113 | + (int) ((($this->getHeight() - $watermark->getHeight()) / 2) * self::POSITIONS[strtoupper($position)]['y']) + self::POSITIONS[strtoupper($position)]['padY'] |
|
114 | 114 | ); |
115 | 115 | } |
116 | 116 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | $newWidth = $width; |
123 | 123 | |
124 | 124 | $this->getWidth() / $this->getHeight() >= $width / $height |
125 | - ? $newWidth = (int)($this->getWidth() / ($this->getHeight() / $height)) |
|
126 | - : $newHeight = (int)($this->getHeight() / ($this->getWidth() / $width)); |
|
125 | + ? $newWidth = (int) ($this->getWidth() / ($this->getHeight() / $height)) |
|
126 | + : $newHeight = (int) ($this->getHeight() / ($this->getWidth() / $width)); |
|
127 | 127 | |
128 | 128 | return $this->prepareThumbnail($width, $height, $newWidth, $newHeight); |
129 | 129 | } |
@@ -240,7 +240,7 @@ |
||
240 | 240 | protected function getImageByURL(string $url): ?\InvalidArgumentException |
241 | 241 | { |
242 | 242 | if (@!getimagesize($url)) { |
243 | - throw new \InvalidArgumentException('Unsupported image type'); |
|
243 | + throw new \InvalidArgumentException('Unsupported image type'); |
|
244 | 244 | } |
245 | 245 | $upload = new \SplFileObject($url, 'rb'); |
246 | 246 | $image = ''; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace Compolomus\Compomage; |
4 | 4 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | imagecopymerge( |
73 | 73 | $this->getImage(), |
74 | 74 | $image = $this->prepareImage($text, $font), |
75 | - (int)((($this->getWidth() - imagesx($image)) / 2) * self::POSITIONS[strtoupper($position)]['x']) + self::POSITIONS[strtoupper($position)]['padX'], |
|
76 | - (int)((($this->getHeight() - imagesy($image)) / 2) * self::POSITIONS[strtoupper($position)]['y']) + self::POSITIONS[strtoupper($position)]['padY'], |
|
75 | + (int) ((($this->getWidth() - imagesx($image)) / 2) * self::POSITIONS[strtoupper($position)]['x']) + self::POSITIONS[strtoupper($position)]['padX'], |
|
76 | + (int) ((($this->getHeight() - imagesy($image)) / 2) * self::POSITIONS[strtoupper($position)]['y']) + self::POSITIONS[strtoupper($position)]['padY'], |
|
77 | 77 | 0, |
78 | 78 | 0, |
79 | 79 | $this->getWidth(), |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | $maxX = max([$coordinates[0], $coordinates[2], $coordinates[4], $coordinates[6]]); |
102 | 102 | $minY = min([$coordinates[1], $coordinates[3], $coordinates[5], $coordinates[7]]); |
103 | 103 | $maxY = max([$coordinates[1], $coordinates[3], $coordinates[5], $coordinates[7]]); |
104 | - $textX = (int)abs($minX) + 1; |
|
105 | - $textY = (int)abs($minY) + 1; |
|
104 | + $textX = (int) abs($minX) + 1; |
|
105 | + $textY = (int) abs($minY) + 1; |
|
106 | 106 | $image = $this->newImage($maxX - $minX + 2, $maxY - $minY + 2); |
107 | 107 | imagecolortransparent($image, $white = imagecolorallocate($image, 0, 0, 0)); |
108 | 108 | imagefilledrectangle($image, 0, 0, $this->getWidth(), 20, $white); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function save(string $filename, $quality = 100): bool |
214 | 214 | { |
215 | - return imagepng($this->getImage(), $filename . '.png', (int)($quality / 11), PNG_ALL_FILTERS); |
|
215 | + return imagepng($this->getImage(), $filename . '.png', (int) ($quality / 11), PNG_ALL_FILTERS); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | imagecopyresampled( |
232 | 232 | $newimage = $this->newImage($width, $height), |
233 | 233 | $this->getImage(), |
234 | - 0 - (int)(($newWidth - $width) / 2), |
|
235 | - 0 - (int)(($newHeight - $height) / 2), |
|
234 | + 0 - (int) (($newWidth - $width) / 2), |
|
235 | + 0 - (int) (($newHeight - $height) / 2), |
|
236 | 236 | 0, |
237 | 237 | 0, |
238 | 238 | $newWidth, |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | $y, |
284 | 284 | 0, |
285 | 285 | 0, |
286 | - $width = (int)$watermark->getWidth(), |
|
287 | - $height = (int)$watermark->getHeight(), |
|
286 | + $width = (int) $watermark->getWidth(), |
|
287 | + $height = (int) $watermark->getHeight(), |
|
288 | 288 | $width, |
289 | 289 | $height |
290 | 290 | ); |
@@ -38,23 +38,23 @@ |
||
38 | 38 | |
39 | 39 | // test Imagick |
40 | 40 | |
41 | - (new Image(base64_encode(file_get_contents('../test.jpg')), Image::IMAGICK)) |
|
42 | - ->copyright('Test', 'Courier', 'CENTER') |
|
43 | - ->thumbnail(170, 180) |
|
44 | - ->save('test2'); |
|
41 | + (new Image(base64_encode(file_get_contents('../test.jpg')), Image::IMAGICK)) |
|
42 | + ->copyright('Test', 'Courier', 'CENTER') |
|
43 | + ->thumbnail(170, 180) |
|
44 | + ->save('test2'); |
|
45 | 45 | |
46 | - $img = new Image($base64_image, Image::IMAGICK); |
|
47 | - $img->thumbnail(200, 100); |
|
48 | - echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />'; |
|
49 | - echo '<pre>' . print_r($img, true) . '</pre>'; |
|
50 | - $img->save('thumbnail_test1_im'); |
|
46 | + $img = new Image($base64_image, Image::IMAGICK); |
|
47 | + $img->thumbnail(200, 100); |
|
48 | + echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />'; |
|
49 | + echo '<pre>' . print_r($img, true) . '</pre>'; |
|
50 | + $img->save('thumbnail_test1_im'); |
|
51 | 51 | |
52 | - $img = new Image($base64_image1, Image::IMAGICK); |
|
53 | - $img->thumbnail(170, 180); |
|
54 | - echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />'; |
|
55 | - echo '<pre>' . print_r($img, true) . '</pre>'; |
|
56 | - // save Imagick test |
|
57 | - $img->save('thumbnail_test2_im'); |
|
52 | + $img = new Image($base64_image1, Image::IMAGICK); |
|
53 | + $img->thumbnail(170, 180); |
|
54 | + echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />'; |
|
55 | + echo '<pre>' . print_r($img, true) . '</pre>'; |
|
56 | + // save Imagick test |
|
57 | + $img->save('thumbnail_test2_im'); |
|
58 | 58 | } else { |
59 | - echo 'Imagick not supported'; |
|
59 | + echo 'Imagick not supported'; |
|
60 | 60 | } |
@@ -19,12 +19,12 @@ |
||
19 | 19 | if (extension_loaded('imagick')) { |
20 | 20 | // test Imagick |
21 | 21 | |
22 | - $img = new Image($base64_image, Image::IMAGICK); |
|
23 | - $watermark = new Image('ImageMagick.png', Image::IMAGICK); |
|
24 | - $watermark->resizeByHeight(100); |
|
25 | - $img->watermark($watermark, 'CENTER'); |
|
26 | - $img->copyright('Imagick test', 'Courier', 'SOUTHEAST'); |
|
27 | - echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />'; |
|
22 | + $img = new Image($base64_image, Image::IMAGICK); |
|
23 | + $watermark = new Image('ImageMagick.png', Image::IMAGICK); |
|
24 | + $watermark->resizeByHeight(100); |
|
25 | + $img->watermark($watermark, 'CENTER'); |
|
26 | + $img->copyright('Imagick test', 'Courier', 'SOUTHEAST'); |
|
27 | + echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />'; |
|
28 | 28 | } else { |
29 | - echo 'Imagick not supported'; |
|
29 | + echo 'Imagick not supported'; |
|
30 | 30 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | $obj = new Image($args['image'], Image::GD); // Image::IMAGICK |
15 | 15 | return '<img src="data:image/png;base64,' . $obj->crop((int) $args['width'], (int) $args['height'], (int) $args['x'], (int) $args['y'])->getBase64() . '" alt="base64_image" />' |
16 | - . '<div>input w h x y = ' . implode(' | ', [$args['width'], $args['height'], $args['x'], $args['y']]) . '</div>'; |
|
16 | + . '<div>input w h x y = ' . implode(' | ', [$args['width'], $args['height'], $args['x'], $args['y']]) . '</div>'; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | echo out_base64($_REQUEST); |