/** * Merges the image specified as the argument into the main picture. * * @param ImageMagick $backgroundImage * @return ImageMagick */ public function mergeImage(ImageMagick $backgroundImage) { $this->setTmpPaths($this, 'merge'); $this->save($this->getOutputPath()); //save the current state of the file (with a background) $this->compositeCommandOptions = []; $this->addCompositeOption('gravity', 'center ' . $this->getOutputPath() . ' ' . $backgroundImage->getOutputPath() . ' ' . $this->getOutputPath()); $this->processCommand($this->getCompositeCommand()); $this->imagePath = $this->getOutputPath(); $this->tmpFiles[] = $this->getOutputPath(); return $this; }