1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109:
<?php
class ComponentImage extends Component
{
const IMG_DIRECTORY = 'img/';
private $width;
private $height;
private $image;
private $composite;
private $filter;
public function __construct(
OsuSignature $signature,
$x = 0,
$y = 0,
$image,
$composite = Imagick::COMPOSITE_DEFAULT,
$width = -1,
$height = -1,
$filter = Imagick::FILTER_CATROM) {
parent::__construct($signature, $x, $y);
if ($image instanceof Imagick) {
$this->image = $image;
} else {
$this->image = new Imagick($image);
}
$this->width = $width;
$this->height = $height;
$this->composite = $composite;
$this->filter = $filter;
}
public function getWidth() {
return $this->width;
}
public function getHeight() {
return $this->height;
}
public function draw(OsuSignature $signature) {
parent::draw($signature);
if ($this->width != -1 || $this->height != -1) {
$this->image->resizeImage(
$this->width == -1 ? $this->image->getImageWidth() : $this->width,
$this->height == -1 ? $this->image->getImageHeight() : $this->height,
1,
$this->filter
);
}
$signature->getCanvas()->compositeImage(
$this->image,
$this->composite,
$this->x,
$this->y
);
}
}