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:
<?php
class Signature
{
protected $canvas;
public function __construct($width, $height) {
$this->canvas = new\Imagick();
$this->canvas->newImage($width, $height, new ImagickPixel('transparent'));
}
protected function drawBackground($hexColour) {
$background = new ImagickDraw();
$background->setFillColor($hexColour);
$background->rectangle(0, 0, $this->canvas->getImageWidth(), $this->canvas->getImageHeight());
$this->canvas->drawImage($background);
}
public function output() {
$cachingTime = isset($_GET['onlineindicator']) ? 60 : 300;
$this->canvas->setImageFormat('png');
header('Content-Type: image/'.$this->canvas->getImageFormat());
header("Cache-Control: max-age=$cachingTime");
header("Expires: ".gmdate("D, d M Y H:i:s", time()+$cachingTime)." GMT");
$this->canvas->setImageProperty('Generated by', 'Lemmmy\'s osu!next signature generator');
$this->canvas->setImageProperty('Generator URL', 'http://lemmmy.pw/osusig/');
echo $this->canvas;
}
public function getCanvas() {
return $this->canvas;
}
}