public function addOverlay($image, $x = 0, $y = 0, $alpha = 100, $composite = "COMPOSITE_DEFAULT", $origin = 'top-left')
{
$this->saveIfRequired('overlay_first_step');
$image = PIMCORE_DOCUMENT_ROOT . "/" . ltrim($image, "/");
if (is_file($image)) {
//if a specified file as a overlay exists
$overlayImage = $this->createTmpImage($image, 'overlay');
$overlayImage->setForceAlpha(true)->addConvertOption('evaluate', "set {$alpha}%");
//defines the position in order to the origin value
switch ($origin) {
case "top-right":
$x = $this->getWidth() - $overlayImage->getWidth() - $x;
break;
case "bottom-left":
$y = $this->getHeight() - $overlayImage->getHeight() - $y;
break;
case "bottom-right":
$x = $this->getWidth() - $overlayImage->getWidth() - $x;
$y = $this->getHeight() - $overlayImage->getHeight() - $y;
break;
case "center":
$x = round($this->getWidth() / 2) - round($overlayImage->getWidth() / 2) + $x;
$y = round($this->getHeight() / 2) - round($overlayImage->getHeight() / 2) + $y;
break;
}
//top the overlay image
$overlayImage->save($overlayImage->getOutputPath());
$this->processOverlay($overlayImage, $composite, $x, $y, $alpha);
}
return $this;
}