Skip to content

Commit

Permalink
TASK: Add temporary adjustment for visualizing the fp in rendered thu…
Browse files Browse the repository at this point in the history
…mbnails
  • Loading branch information
mficzel committed Jul 15, 2024
1 parent 9d0f47e commit a99ccaa
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
95 changes: 95 additions & 0 deletions Neos.Media/Classes/Domain/Model/Adjustment/MarkPointAdjustment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
declare(strict_types=1);

namespace Neos\Media\Domain\Model\Adjustment;

/*
* This file is part of the Neos.Media package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use Imagine\Image\ImageInterface as ImagineImageInterface;
use Imagine\Image\Point;
use Neos\Flow\Annotations as Flow;
use Imagine\Image\Palette;

/**
* An adjustment to draw on circle on an image
* this is solely for debugging of focal points
* @todo remove before merging
*
* @deprecated
* @Flow\Entity
*/
class MarkPointAdjustment extends AbstractImageAdjustment
{
protected $position = 99;

protected int $x;

protected int $y;

protected int $radius;

protected int $thickness = 1;

protected string $color = '#000';


public function setX(int $x): void
{
$this->x = $x;
}

public function setY(int $y): void
{
$this->y = $y;
}

public function setRadius(int $radius): void
{
$this->radius = $radius;
}

public function setThickness(int $thickness): void
{
$this->thickness = $thickness;
}

public function setColor(string $color): void
{
$this->color = $color;
}


public function applyToImage(ImagineImageInterface $image)
{
$palette = new Palette\RGB();
$color = $palette->color($this->color);
$image->draw()
->circle(
new Point($this->x, $this->y),
$this->radius,
$color,
false,
$this->thickness
)
;

return $image;
}

public function canBeApplied(ImagineImageInterface $image)
{
if (is_null($this->x) || is_null($this->y) || is_null($this->radius)) {
return false;
}
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Neos\Media\Domain\Model\Adjustment\CropImageAdjustment;
use Neos\Media\Domain\Model\Adjustment\FocalPointCropSpecification;
use Neos\Media\Domain\Model\Adjustment\ImageDimensionCalculationHelperThingy;
use Neos\Media\Domain\Model\Adjustment\MarkPointAdjustment;
use Neos\Media\Domain\Model\Adjustment\QualityImageAdjustment;
use Neos\Media\Domain\Model\Adjustment\ResizeImageAdjustment;
use Neos\Media\Domain\Model\FocalPointSupportInterface;
Expand Down Expand Up @@ -116,7 +117,20 @@ public function refresh(Thumbnail $thumbnail)
]
)
],
$adjustments
$adjustments,
[
// this is for debugging purposes only
// @todo remove before merging
new MarkPointAdjustment(
[
'x' => $focalPointCropSpec->croppedFocalPoint->getX(),
'y' => $focalPointCropSpec->croppedFocalPoint->getY(),
'radius' => 5,
'color' => '#0f0',
'thickness' => 4
]
),
]
);
}

Expand Down

0 comments on commit a99ccaa

Please sign in to comment.