@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | if (class_exists($driverClassName)) {
|
| 278 | 278 | if ($this->config->offsetExists($driverOffset)) {
|
| 279 | - $config = $this->config[ $driverOffset ]; |
|
| 279 | + $config = $this->config[$driverOffset]; |
|
| 280 | 280 | } else {
|
| 281 | 281 | $config = $this->config->getArrayCopy(); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if (isset($config[ 'engine' ])) {
|
|
| 285 | - unset($config[ 'engine' ]); |
|
| 284 | + if (isset($config['engine'])) {
|
|
| 285 | + unset($config['engine']); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $this->driver = new $driverClassName(); |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | if (empty($mime)) {
|
| 546 | 546 | $mime = $this->driver->getSourceImageFile()->getMime(); |
| 547 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 547 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 548 | 548 | |
| 549 | 549 | $extension = $this->driver->getMimeExtension($mime); |
| 550 | 550 | } |
@@ -586,14 +586,14 @@ discard block |
||
| 586 | 586 | if ($optimizerConfig === 'default') {
|
| 587 | 587 | $optimizer = new Optimizer(); |
| 588 | 588 | $optimizer->optimize($saveImageFilePath); |
| 589 | - } elseif ( ! empty($optimizerConfig[ 'factory' ])) {
|
|
| 590 | - $factory = $optimizerConfig[ 'factory' ]; |
|
| 589 | + } elseif ( ! empty($optimizerConfig['factory'])) {
|
|
| 590 | + $factory = $optimizerConfig['factory']; |
|
| 591 | 591 | $optimizer = new Optimizer(); |
| 592 | 592 | |
| 593 | 593 | switch ($factory) {
|
| 594 | 594 | case 'imageoptim'; |
| 595 | 595 | $factory = new Imageoptim(); |
| 596 | - $factory->setUsername($optimizerConfig[ 'username' ]); |
|
| 596 | + $factory->setUsername($optimizerConfig['username']); |
|
| 597 | 597 | $optimizer->setImageFactory($factory); |
| 598 | 598 | break; |
| 599 | 599 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | } catch (\GmagickException $e) {
|
| 81 | 81 | |
| 82 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 82 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function rotate($degrees) |
| 101 | 101 | {
|
| 102 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 102 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 103 | 103 | |
| 104 | 104 | try {
|
| 105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | } catch (\GmagickException $e) {
|
| 111 | 111 | |
| 112 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 112 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 113 | 113 | |
| 114 | 114 | } |
| 115 | 115 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ]; |
| 137 | 137 | |
| 138 | 138 | if (array_key_exists($axis, $gdAxis)) {
|
| 139 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 139 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 140 | 140 | |
| 141 | 141 | try {
|
| 142 | 142 | switch ($axis) {
|
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | } catch (\GmagickException $e) {
|
| 158 | 158 | |
| 159 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 159 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $resizeWidth = $sourceDimension->getWidth() * $resizeRatio; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 202 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 203 | 203 | |
| 204 | 204 | try {
|
| 205 | 205 | $resampleImageResource->resizeimage($resizeWidth, $resizeHeight, |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | } catch (\GmagickException $e) {
|
| 211 | 211 | |
| 212 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 212 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 213 | 213 | |
| 214 | 214 | return false; |
| 215 | 215 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $resizeWidth = $sourceDimension->getWidth() * $resizeRatio; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 238 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 239 | 239 | |
| 240 | 240 | if ($resampleDimension->getOrientation() === 'SQUARE') {
|
| 241 | 241 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | } catch (\GmagickException $e) {
|
| 251 | 251 | |
| 252 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 252 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 253 | 253 | |
| 254 | 254 | return false; |
| 255 | 255 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | } catch (\GmagickException $e) {
|
| 322 | 322 | |
| 323 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 323 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 324 | 324 | |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function crop(Dimension $dimension) |
| 343 | 343 | {
|
| 344 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 344 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 345 | 345 | |
| 346 | 346 | try {
|
| 347 | 347 | |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | } catch (\GmagickException $e) {
|
| 358 | 358 | |
| 359 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 359 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 360 | 360 | |
| 361 | 361 | } |
| 362 | 362 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function watermark(AbstractWatermark $watermark) |
| 376 | 376 | {
|
| 377 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 377 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 378 | 378 | |
| 379 | 379 | if ($watermark instanceof Text) {
|
| 380 | 380 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | |
| 443 | 443 | } catch (\GmagickException $e) {
|
| 444 | 444 | |
| 445 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 445 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 446 | 446 | |
| 447 | 447 | } |
| 448 | 448 | } elseif ($watermark instanceof Overlay) {
|
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | return true; |
| 539 | 539 | } catch (\GmagickException $e) {
|
| 540 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 540 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | public function scale() |
| 572 | 572 | {
|
| 573 | 573 | $resampleDimension = $this->resampleImageFile->getDimension(); |
| 574 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 574 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 575 | 575 | |
| 576 | 576 | try {
|
| 577 | 577 | |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | } catch (\GmagickException $e) {
|
| 587 | 587 | |
| 588 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 588 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 589 | 589 | |
| 590 | 590 | } |
| 591 | 591 | |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | if (empty($mime)) {
|
| 610 | 610 | $mime = $this->sourceImageFile->getMime(); |
| 611 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 611 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 612 | 612 | |
| 613 | 613 | $extension = $this->getMimeExtension($mime); |
| 614 | 614 | } |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | if (empty($mime)) {
|
| 647 | 647 | $mime = $this->sourceImageFile->getMime(); |
| 648 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 648 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 649 | 649 | |
| 650 | 650 | $extension = $this->getMimeExtension($mime); |
| 651 | 651 | } |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | public function save($imageTargetFilePath, $quality = 100) |
| 677 | 677 | {
|
| 678 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 678 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 679 | 679 | $resampleImageResource->setCompressionQuality($quality); |
| 680 | 680 | $resampleImageResource->stripimage(); |
| 681 | 681 | |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | } catch (\GmagickException $e) {
|
| 714 | 714 | |
| 715 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 715 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 716 | 716 | |
| 717 | 717 | } |
| 718 | 718 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function rotate($degrees) |
| 73 | 73 | {
|
| 74 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 74 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 75 | 75 | |
| 76 | 76 | // Set the background color |
| 77 | 77 | // This won't work with transparent PNG files so we are |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | ]; |
| 104 | 104 | |
| 105 | 105 | if (array_key_exists($axis, $gdAxis)) {
|
| 106 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 106 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 107 | 107 | imageflip($resampleImageResource, $axis); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | public function crop(Dimension $dimension) |
| 381 | 381 | {
|
| 382 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 382 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 383 | 383 | |
| 384 | 384 | if (false !== ($resampleCropImage = imagecrop($resampleImageResource, [ |
| 385 | 385 | 'x' => $dimension->getAxis()->getX(), |
@@ -407,23 +407,23 @@ discard block |
||
| 407 | 407 | */ |
| 408 | 408 | public function watermark(AbstractWatermark $watermark) |
| 409 | 409 | {
|
| 410 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 410 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 411 | 411 | |
| 412 | 412 | if ($watermark instanceof Text) {
|
| 413 | 413 | $textBox = imagettfbbox($watermark->getFontSize(), $watermark->getAngle(), $watermark->getFontPath(), |
| 414 | 414 | $watermark->getString()); |
| 415 | 415 | |
| 416 | - if ($textBox[ 0 ] < 0 and $textBox[ 6 ]) {
|
|
| 417 | - $textBox[ 1 ] += $textBox[ 0 ]; |
|
| 418 | - $textBox[ 3 ] += $textBox[ 0 ]; |
|
| 419 | - $textBox[ 5 ] += $textBox[ 0 ]; |
|
| 420 | - $textBox[ 7 ] += $textBox[ 0 ]; |
|
| 416 | + if ($textBox[0] < 0 and $textBox[6]) {
|
|
| 417 | + $textBox[1] += $textBox[0]; |
|
| 418 | + $textBox[3] += $textBox[0]; |
|
| 419 | + $textBox[5] += $textBox[0]; |
|
| 420 | + $textBox[7] += $textBox[0]; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $textBox = array_map('abs', $textBox);
|
| 424 | 424 | |
| 425 | - $watermarkImageWidth = max($textBox[ 0 ], $textBox[ 2 ], $textBox[ 4 ], $textBox[ 6 ]); |
|
| 426 | - $watermarkImageHeight = max($textBox[ 1 ], $textBox[ 3 ], $textBox[ 5 ], $textBox[ 7 ]); |
|
| 425 | + $watermarkImageWidth = max($textBox[0], $textBox[2], $textBox[4], $textBox[6]); |
|
| 426 | + $watermarkImageHeight = max($textBox[1], $textBox[3], $textBox[5], $textBox[7]); |
|
| 427 | 427 | |
| 428 | 428 | if (false !== ($watermarkAxis = $watermark->getAxis())) {
|
| 429 | 429 | $watermarkImageAxisX = $watermarkAxis->getX(); |
@@ -487,9 +487,9 @@ discard block |
||
| 487 | 487 | * hex values: |
| 488 | 488 | */ |
| 489 | 489 | $textColor = str_split(substr($watermark->getFontColor(), 1, 6), 2); |
| 490 | - $textColor = imagecolorclosest($resampleImageResource, hexdec($textColor[ 0 ]), |
|
| 491 | - hexdec($textColor[ 1 ]), |
|
| 492 | - hexdec($textColor[ 2 ])); |
|
| 490 | + $textColor = imagecolorclosest($resampleImageResource, hexdec($textColor[0]), |
|
| 491 | + hexdec($textColor[1]), |
|
| 492 | + hexdec($textColor[2])); |
|
| 493 | 493 | |
| 494 | 494 | imagettftext( |
| 495 | 495 | $resampleImageResource, |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | ini_set('gd.jpeg_ignore_warning', 1);
|
| 626 | 626 | |
| 627 | 627 | $mime = $this->sourceImageFile->getMime(); |
| 628 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 628 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 629 | 629 | |
| 630 | 630 | try {
|
| 631 | 631 | switch ($mime) {
|
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if (empty($mime)) {
|
| 737 | 737 | $mime = $this->sourceImageFile->getMime(); |
| 738 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 738 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 739 | 739 | |
| 740 | 740 | $extensions = [ |
| 741 | 741 | 'image/gif' => 'gif', |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | 'image/webp' => 'webp', |
| 746 | 746 | ]; |
| 747 | 747 | |
| 748 | - $extension = $extensions[ $mime ]; |
|
| 748 | + $extension = $extensions[$mime]; |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | header('Content-Disposition: filename=' . $filename . '.' . $extension);
|
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | |
| 781 | 781 | if (empty($mime)) {
|
| 782 | 782 | $mime = $this->sourceImageFile->getMime(); |
| 783 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 783 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 784 | 784 | |
| 785 | 785 | $extension = $this->getMimeExtension($mime); |
| 786 | 786 | } |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | */ |
| 811 | 811 | public function save($imageTargetFilePath, $quality = 100) |
| 812 | 812 | {
|
| 813 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 813 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 814 | 814 | |
| 815 | 815 | $extension = pathinfo($imageTargetFilePath, PATHINFO_EXTENSION); |
| 816 | 816 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | } catch (\ImagickException $e) {
|
| 79 | 79 | |
| 80 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 80 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function rotate($degrees) |
| 99 | 99 | {
|
| 100 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 100 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 101 | 101 | |
| 102 | 102 | return $resampleImageResource->rotateImage('#000000', $degrees);
|
| 103 | 103 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | ]; |
| 123 | 123 | |
| 124 | 124 | if (array_key_exists($axis, $gdAxis)) {
|
| 125 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 125 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 126 | 126 | |
| 127 | 127 | try {
|
| 128 | 128 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | return true; |
| 143 | 143 | |
| 144 | 144 | } catch (\ImagickException $e) {
|
| 145 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 145 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $resizeWidth = $sourceDimension->getWidth() * $resizeRatio; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 187 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 188 | 188 | |
| 189 | 189 | return $resampleImageResource->resizeImage( |
| 190 | 190 | $resizeWidth, |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $resizeWidth = $sourceDimension->getWidth() * $resizeRatio; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 215 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 216 | 216 | |
| 217 | 217 | if ($resampleDimension->getOrientation() === 'SQUARE') {
|
| 218 | 218 | if ($resampleImageResource->resizeImage($resizeWidth, $resizeHeight, \Imagick::FILTER_LANCZOS, 0.9, |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function crop(Dimension $dimension) |
| 313 | 313 | {
|
| 314 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 314 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 315 | 315 | |
| 316 | 316 | try {
|
| 317 | 317 | return $resampleImageResource->cropImage( |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $dimension->getAxis()->getY() |
| 322 | 322 | ); |
| 323 | 323 | } catch (\ImagickException $e) {
|
| 324 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 324 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | return false; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | public function watermark(AbstractWatermark $watermark) |
| 340 | 340 | {
|
| 341 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 341 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 342 | 342 | |
| 343 | 343 | if ($watermark instanceof Text) {
|
| 344 | 344 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | |
| 492 | 492 | return true; |
| 493 | 493 | } catch (\ImagickException $e) {
|
| 494 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 494 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | } |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | {
|
| 527 | 527 | $resampleDimension = $this->resampleImageFile->getDimension(); |
| 528 | 528 | |
| 529 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 529 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 530 | 530 | |
| 531 | 531 | try {
|
| 532 | 532 | return $resampleImageResource->scaleImage($resampleDimension->getWidth(), $resampleDimension->getHeight(), |
| 533 | 533 | true); |
| 534 | 534 | } catch (\ImagickException $e) {
|
| 535 | - $this->errors[ $e->getCode() ] = $e->getMessage(); |
|
| 535 | + $this->errors[$e->getCode()] = $e->getMessage(); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | return false; |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | if (empty($mime)) {
|
| 556 | 556 | $mime = $this->sourceImageFile->getMime(); |
| 557 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 557 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 558 | 558 | |
| 559 | 559 | $extension = $this->getMimeExtension($mime); |
| 560 | 560 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | if (empty($mime)) {
|
| 593 | 593 | $mime = $this->sourceImageFile->getMime(); |
| 594 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
| 594 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
| 595 | 595 | |
| 596 | 596 | $extension = $this->getMimeExtension($mime); |
| 597 | 597 | } |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | public function save($imageTargetFilePath, $quality = 100) |
| 625 | 625 | {
|
| 626 | - $resampleImageResource =& $this->getResampleImageResource(); |
|
| 626 | + $resampleImageResource = & $this->getResampleImageResource(); |
|
| 627 | 627 | |
| 628 | 628 | $extension = pathinfo($imageTargetFilePath, PATHINFO_EXTENSION); |
| 629 | 629 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function setMinWidthSize($size) |
| 79 | 79 | {
|
| 80 | - $this->allowedImageSize[ 'width' ][ 'min' ] = (int)$size; |
|
| 80 | + $this->allowedImageSize['width']['min'] = (int)$size; |
|
| 81 | 81 | |
| 82 | 82 | return $this; |
| 83 | 83 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | public function setMaxWidthSize($size) |
| 88 | 88 | {
|
| 89 | - $this->allowedImageSize[ 'width' ][ 'max' ] = (int)$size; |
|
| 89 | + $this->allowedImageSize['width']['max'] = (int)$size; |
|
| 90 | 90 | |
| 91 | 91 | return $this; |
| 92 | 92 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | public function setMinHeightSize($size) |
| 97 | 97 | {
|
| 98 | - $this->allowedImageSize[ 'height' ][ 'min' ] = (int)$size; |
|
| 98 | + $this->allowedImageSize['height']['min'] = (int)$size; |
|
| 99 | 99 | |
| 100 | 100 | return $this; |
| 101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public function setMaxHeightSize($size) |
| 106 | 106 | {
|
| 107 | - $this->allowedImageSize[ 'height' ][ 'max' ] = (int)$size; |
|
| 107 | + $this->allowedImageSize['height']['max'] = (int)$size; |
|
| 108 | 108 | |
| 109 | 109 | return $this; |
| 110 | 110 | } |
@@ -116,45 +116,45 @@ discard block |
||
| 116 | 116 | if (parent::validate($file)) {
|
| 117 | 117 | |
| 118 | 118 | $info = getimagesize($file->getFileTemp()); |
| 119 | - $width = $info[ 0 ]; |
|
| 120 | - $height = $info[ 1 ]; |
|
| 119 | + $width = $info[0]; |
|
| 120 | + $height = $info[1]; |
|
| 121 | 121 | |
| 122 | 122 | /* Validate width min size */ |
| 123 | - if ($this->allowedImageSize[ 'width' ][ 'min' ] > 0) {
|
|
| 124 | - if ($width < $this->allowedImageSize[ 'width' ][ 'min' ]) {
|
|
| 123 | + if ($this->allowedImageSize['width']['min'] > 0) {
|
|
| 124 | + if ($width < $this->allowedImageSize['width']['min']) {
|
|
| 125 | 125 | $this->errors[] = language()->getLine( |
| 126 | 126 | 'IMAGE_E_ALLOWED_MIN_WIDTH_SIZE', |
| 127 | - [$this->allowedFileSize[ 'min' ], $width] |
|
| 127 | + [$this->allowedFileSize['min'], $width] |
|
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /* Validate width max size */ |
| 133 | - if ($this->allowedImageSize[ 'width' ][ 'max' ] > 0) {
|
|
| 134 | - if ($width > $this->allowedImageSize[ 'width' ][ 'max' ]) {
|
|
| 133 | + if ($this->allowedImageSize['width']['max'] > 0) {
|
|
| 134 | + if ($width > $this->allowedImageSize['width']['max']) {
|
|
| 135 | 135 | $this->errors[] = language()->getLine( |
| 136 | 136 | 'IMAGE_E_ALLOWED_MAX_WIDTH_SIZE', |
| 137 | - [$this->allowedFileSize[ 'max' ], $width] |
|
| 137 | + [$this->allowedFileSize['max'], $width] |
|
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /* Validate height min size */ |
| 143 | - if ($this->allowedImageSize[ 'height' ][ 'min' ] > 0) {
|
|
| 144 | - if ($height < $this->allowedImageSize[ 'width' ][ 'min' ]) {
|
|
| 143 | + if ($this->allowedImageSize['height']['min'] > 0) {
|
|
| 144 | + if ($height < $this->allowedImageSize['width']['min']) {
|
|
| 145 | 145 | $this->errors[] = language()->getLine( |
| 146 | 146 | 'IMAGE_E_ALLOWED_MIN_HEIGHT_SIZE', |
| 147 | - [$this->allowedFileSize[ 'min' ], $height] |
|
| 147 | + [$this->allowedFileSize['min'], $height] |
|
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /* Validate height max size */ |
| 153 | - if ($this->allowedImageSize[ 'height' ][ 'max' ] > 0) {
|
|
| 154 | - if ($height > $this->allowedImageSize[ 'width' ][ 'max' ]) {
|
|
| 153 | + if ($this->allowedImageSize['height']['max'] > 0) {
|
|
| 154 | + if ($height > $this->allowedImageSize['width']['max']) {
|
|
| 155 | 155 | $this->errors[] = language()->getLine( |
| 156 | 156 | 'IMAGE_E_ALLOWED_MAX_HEIGHT_SIZE', |
| 157 | - [$this->allowedFileSize[ 'max' ], $height] |
|
| 157 | + [$this->allowedFileSize['max'], $height] |
|
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -73,10 +73,10 @@ |
||
| 73 | 73 | |
| 74 | 74 | // Set image file properties |
| 75 | 75 | if (false !== ($imageSize = getimagesize($filePath))) {
|
| 76 | - $this->dimension = new Dimension($imageSize[ 0 ], $imageSize[ 1 ]); |
|
| 77 | - $this->bits = $imageSize[ 'bits' ]; |
|
| 78 | - $this->channels = isset($imageSize[ 'channels' ]) ? $imageSize[ 'channels' ] : 0; |
|
| 79 | - $this->type = $imageSize[ 2 ]; |
|
| 76 | + $this->dimension = new Dimension($imageSize[0], $imageSize[1]); |
|
| 77 | + $this->bits = $imageSize['bits']; |
|
| 78 | + $this->channels = isset($imageSize['channels']) ? $imageSize['channels'] : 0; |
|
| 79 | + $this->type = $imageSize[2]; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -42,10 +42,10 @@ |
||
| 42 | 42 | |
| 43 | 43 | $config = array_merge($defaultConfig, $config); |
| 44 | 44 | |
| 45 | - if ($config[ 'driver' ] === 'imagick') {
|
|
| 46 | - $config[ 'driver' ] = 'imagemagick'; |
|
| 47 | - } elseif ($config[ 'driver' ] === 'gmagick') {
|
|
| 48 | - $config[ 'driver' ] = 'graphicsmagick'; |
|
| 45 | + if ($config['driver'] === 'imagick') {
|
|
| 46 | + $config['driver'] = 'imagemagick'; |
|
| 47 | + } elseif ($config['driver'] === 'gmagick') {
|
|
| 48 | + $config['driver'] = 'graphicsmagick'; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | parent::__construct($config); |
@@ -134,53 +134,53 @@ |
||
| 134 | 134 | $boundary = "XXX$contentHash"; |
| 135 | 135 | $nameEscaped = addslashes(basename($image)); |
| 136 | 136 | |
| 137 | - $options[ 'content' ] = "--$boundary\r\n" . |
|
| 137 | + $options['content'] = "--$boundary\r\n" . |
|
| 138 | 138 | "Content-Disposition: form-data; name=\"file\"; filename=\"{$nameEscaped}\"\r\n" .
|
| 139 | 139 | "Content-Type: application/octet-stream\r\n" . |
| 140 | 140 | "Content-Transfer-Encoding: binary\r\n" . |
| 141 | 141 | "\r\n$fileData\r\n--$boundary--"; |
| 142 | 142 | |
| 143 | - $options[ 'header' ] = |
|
| 143 | + $options['header'] = |
|
| 144 | 144 | "Accept: image/*,application/im2+json\r\n" . |
| 145 | 145 | "User-Agent: ImageOptim-php/1.1 PHP/" . phpversion() . |
| 146 | - "Content-Length: " . strlen($options[ 'content' ]) . "\r\n" . |
|
| 146 | + "Content-Length: " . strlen($options['content']) . "\r\n" . |
|
| 147 | 147 | "Content-MD5: $contentHash\r\n" . |
| 148 | 148 | "Content-Type: multipart/form-data, boundary=$boundary\r\n"; |
| 149 | 149 | |
| 150 | - $options[ 'timeout' ] = 30; |
|
| 151 | - $options[ 'ignore_errors' ] = true; |
|
| 152 | - $options[ 'method' ] = 'POST'; |
|
| 150 | + $options['timeout'] = 30; |
|
| 151 | + $options['ignore_errors'] = true; |
|
| 152 | + $options['method'] = 'POST'; |
|
| 153 | 153 | |
| 154 | 154 | $stream = @fopen($callApiUrl, 'r', false, stream_context_create(['http' => $options])); |
| 155 | 155 | if ( ! $stream) {
|
| 156 | 156 | $error = error_get_last(); |
| 157 | - throw new RuntimeException("Can't send HTTPS request to: $callApiUrl\n" . ($error ? $error[ 'message' ] : ''));
|
|
| 157 | + throw new RuntimeException("Can't send HTTPS request to: $callApiUrl\n" . ($error ? $error['message'] : ''));
|
|
| 158 | 158 | } |
| 159 | 159 | $response = @stream_get_contents($stream); |
| 160 | 160 | if ( ! $response) {
|
| 161 | 161 | $error = error_get_last(); |
| 162 | 162 | fclose($stream); |
| 163 | - throw new RuntimeException("Error reading HTTPS response from: $callApiUrl\n" . ($error ? $error[ 'message' ] : ''));
|
|
| 163 | + throw new RuntimeException("Error reading HTTPS response from: $callApiUrl\n" . ($error ? $error['message'] : ''));
|
|
| 164 | 164 | } |
| 165 | 165 | $meta = @stream_get_meta_data($stream); |
| 166 | 166 | if ( ! $meta) {
|
| 167 | 167 | $error = error_get_last(); |
| 168 | 168 | fclose($stream); |
| 169 | - throw new RuntimeException("Error reading HTTPS response from: $callApiUrl\n" . ($error ? $error[ 'message' ] : ''));
|
|
| 169 | + throw new RuntimeException("Error reading HTTPS response from: $callApiUrl\n" . ($error ? $error['message'] : ''));
|
|
| 170 | 170 | } |
| 171 | 171 | fclose($stream); |
| 172 | - if ( ! $meta || ! isset($meta[ 'wrapper_data' ], $meta[ 'wrapper_data' ][ 0 ])) {
|
|
| 172 | + if ( ! $meta || ! isset($meta['wrapper_data'], $meta['wrapper_data'][0])) {
|
|
| 173 | 173 | throw new RuntimeException("Unable to read headers from HTTP request to: $callApiUrl");
|
| 174 | 174 | } |
| 175 | - if ( ! empty($meta[ 'timed_out' ])) {
|
|
| 175 | + if ( ! empty($meta['timed_out'])) {
|
|
| 176 | 176 | throw new RuntimeException("Request timed out: $callApiUrl", 504);
|
| 177 | 177 | } |
| 178 | - if ( ! preg_match('/HTTP\/[\d.]+ (\d+) (.*)/', $meta[ 'wrapper_data' ][ 0 ], $status)) {
|
|
| 179 | - throw new RuntimeException("Unexpected response: " . $meta[ 'wrapper_data' ][ 0 ]);
|
|
| 178 | + if ( ! preg_match('/HTTP\/[\d.]+ (\d+) (.*)/', $meta['wrapper_data'][0], $status)) {
|
|
| 179 | + throw new RuntimeException("Unexpected response: " . $meta['wrapper_data'][0]);
|
|
| 180 | 180 | } |
| 181 | - $status = intval($status[ 1 ]); |
|
| 182 | - $errorMessage = $status[ 2 ]; |
|
| 183 | - if ($response && preg_grep('/content-type:\s*application\/im2\+json/i', $meta[ 'wrapper_data' ])) {
|
|
| 181 | + $status = intval($status[1]); |
|
| 182 | + $errorMessage = $status[2]; |
|
| 183 | + if ($response && preg_grep('/content-type:\s*application\/im2\+json/i', $meta['wrapper_data'])) {
|
|
| 184 | 184 | $json = @json_decode($response); |
| 185 | 185 | if ($json) {
|
| 186 | 186 | if (isset($json->status)) {
|
@@ -206,7 +206,7 @@ |
||
| 206 | 206 | ]; |
| 207 | 207 | |
| 208 | 208 | if (array_key_exists($mime, $extensions)) {
|
| 209 | - return $extensions[ $mime ]; |
|
| 209 | + return $extensions[$mime]; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | return false; |