/** * Composites a watermark (the date strings of the image) onto the lower * left corner and the HV logo in the lower right corner. * * Layer names are added together as one string, and date strings are * added as a separate string, to line them up nicely. An example string * would be: * * -annotate +20+0 'EIT 304\nLASCO C2\n' * and: * -annotate +100+0 '2003-01-01 12:00\n2003-01-01 11:30\n' * * These two strings are then layered on top of each other and put in the * southwest corner of the image. * * @param object $imagickImage An Imagick object * * @return void */ private function _addWatermark($imagickImage) { if ($this->width < 200 || $this->height < 200) { return; } $watermark = new IMagick(HV_ROOT_DIR . '/resources/images/' . 'watermark_small_black_border.png'); // If the image is too small, use only the circle, not the url, and // scale it so it fits the image. if ($this->width / 300 < 2) { $watermark->readImage(HV_ROOT_DIR . '/resources/images/' . 'watermark_circle_small_black_border.png'); $scale = $this->width / 2 / 300; $width = $watermark->getImageWidth(); $watermark->scaleImage($width * $scale, $width * $scale); } // For whatever reason, compositeImage() doesn't carry over gravity // settings so the offsets must be relative to the top left corner of // the image rather than the desired gravity. $x = $this->width - $watermark->getImageWidth() - 10; $y = $this->height - $watermark->getImageHeight() - 10; $imagickImage->compositeImage($watermark, IMagick::COMPOSITE_DISSOLVE, $x, $y); // If the image is too small, text won't fit. Don't put a date string // on it. if ($this->width > 285) { $this->_addTimestampWatermark($imagickImage); } // Cleanup $watermark->destroy(); }