ImageMagick   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resizeCommand() 0 8 1
A cropCommand() 0 10 3
1
<?php
2
3
namespace Rvdlee\ZfImageResizer\Adapter;
4
5
use Rvdlee\ZfImageResizer\Model\Image;
6
7
class ImageMagick extends AbstractImageResizer
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $binaryPath = 'convert';
13
14
    public function resizeCommand(Image $image, bool $returnBase64 = false): string
15
    {
16
        return sprintf(
17
            'convert %s -quality 100 -resize %dx%d %s',
18
            $image->getPath(),
19
            $image->getTargetWidth(),
20
            $image->getTargetHeight(),
21
            $image->getTargetPath()
22
        );
23
    }
24
25
    public function cropCommand(Image $image, string $mode = Image::MANUAL_CROP, int $x = 0, int $y = 0): string
26
    {
27
        return sprintf(
28
            'convert %s -crop %dx%d+%d+%d %s',
29
            $image->getPath(),
30
            $image->getTargetWidth(),
31
            $image->getTargetHeight(),
32
            ($mode === Image::MANUAL_CROP ? $x : $image->getCropPositionX()),
33
            ($mode === Image::MANUAL_CROP ? $y : $image->getCropPositionY()),
34
            $image->getTargetPath()
35
        );
36
    }
37
}