Skip to content

Commit

Permalink
Add Imagick::swirlImageWithMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
Danack committed Jan 1, 2022
1 parent fcae30c commit e8fe53b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/ImagickDemo/Imagick/Controls/SwirlImageWithMethodControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types = 1);

namespace ImagickDemo\Imagick\Controls;


use ImagickDemo\Params\InterpolateType;
use ImagickDemo\ToArray;
use Params\Create\CreateFromVarMap;
use Params\InputParameterListFromAttributes;
use Params\SafeAccess;

use ImagickDemo\Params\Image;
use ImagickDemo\Params\Swirl;

class SwirlImageWithMethodControl
{
use SafeAccess;
use CreateFromVarMap;
use ToArray;
use InputParameterListFromAttributes;

public function __construct(
#[Swirl('swirl')]
private string $swirl,
#[InterpolateType('interpolate_method')]
private int $interpolate_method,
#[Image('image_path')]
private string $image_path,
) {
}

public function getValuesForForm(): array
{
return [
'swirl' => $this->swirl,
'interpolate_method' => getOptionFromOptions($this->interpolate_method, getInterpolateOptions()),
'image_path' => getOptionFromOptions($this->image_path, getImagePathOptions()),
];
}
}
10 changes: 10 additions & 0 deletions src/ImagickDemo/Imagick/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,16 @@ function swirlImage($image_path, $swirl)
}
//Example end

//Example Imagick::swirlImageWithMethod
function swirlImageWithMethod($image_path, $swirl, int $interpolate_method)
{
$imagick = new \Imagick(realpath($image_path));
$imagick->swirlImageWithMethod($swirl, $interpolate_method);
header("Content-Type: image/jpeg");
echo $imagick->getImageBlob();
}
//Example end

//Example Imagick::textureImage
function textureImage($image_path)
{
Expand Down
23 changes: 23 additions & 0 deletions src/ImagickDemo/Imagick/swirlImageWithMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace ImagickDemo\Imagick;

use ImagickDemo\Imagick\Controls\SwirlImageWithMethodControl;

class swirlImageWithMethod extends \ImagickDemo\Example
{
public function renderTitle(): string
{
return "Imagick::swirlImageWithMethod";
}

public function useImageControlAsOriginalImage()
{
return true;
}

public static function getParamType(): string
{
return SwirlImageWithMethodControl::class;
}
}
1 change: 1 addition & 0 deletions src/example_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ function getImagickExamples()
'statisticImage' => 'statisticImage',
'subImageMatch' => 'subImageMatch',
'swirlImage' => 'swirlImage',
'swirlImageWithMethod' => 'swirlImageWithMethod',
'textureImage' => 'textureImage',
'thresholdImage' => 'thresholdImage',
'thumbnailImage' => 'thumbnailImage',
Expand Down

0 comments on commit e8fe53b

Please sign in to comment.