public function border($w, $h = null, $type = Gd::INNER_BORDER)
{
$h = null === $h ? $w : $h;
$this->fillColor = $this->strokeColor;
$this->setOpacity(100);
if ($type == self::INNER_BORDER) {
$this->drawRectangle(0, 0, $this->width, $h);
$this->drawRectangle(0, $this->height - $h, $this->width, $this->height);
$this->drawRectangle(0, 0, $w, $this->height);
$this->drawRectangle($this->width - $w, 0, $this->width, $this->height);
} else {
$newWidth = $this->width + $w * 2;
$newHeight = $this->height + $h * 2;
$this->createResource();
$oldResource = $this->resource;
$this->resource = imagecreatetruecolor($newWidth, $newHeight);
$color = $this->setColor($this->fillColor);
imagefill($this->resource, 0, 0, $color);
imagealphablending($this->resource, true);
imagecopy($this->resource, $oldResource, $w, $h, 0, 0, imagesx($oldResource), imagesy($oldResource));
$this->output = $this->resource;
}
return $this;
}