public function resize($maxWidth = 0, $maxHeight = 0)
{
// make sure our arguments are valid
if (!is_numeric($maxWidth)) {
throw new InvalidArgumentException('$maxWidth must be numeric');
}
if (!is_numeric($maxHeight)) {
throw new InvalidArgumentException('$maxHeight must be numeric');
}
// make sure we're not exceeding our image size if we're not supposed to
if ($this->options['resizeUp'] === false) {
$this->maxHeight = intval($maxHeight) > $this->currentDimensions['height'] ? $this->currentDimensions['height'] : $maxHeight;
$this->maxWidth = intval($maxWidth) > $this->currentDimensions['width'] ? $this->currentDimensions['width'] : $maxWidth;
} else {
$this->maxHeight = intval($maxHeight);
$this->maxWidth = intval($maxWidth);
}
// get the new dimensions...
$this->calcImageSize($this->currentDimensions['width'], $this->currentDimensions['height']);
// create the working image
if (function_exists('imagecreatetruecolor')) {
$this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
} else {
$this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
}
$this->preserveAlpha();
// and create the newly sized image
imagecopyresampled($this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height']);
// update all the variables and resources to be correct
$this->oldImage = $this->workingImage;
$this->currentDimensions['width'] = $this->newDimensions['newWidth'];
$this->currentDimensions['height'] = $this->newDimensions['newHeight'];
return $this;
}