protected function scaleImage($scl)
{
// Define the temp scaled image.
$this->scaledImage = \Pop\File\Dir::getUploadTemp() . DIRECTORY_SEPARATOR . $this->img->getFilename() . '_' . time() . '.' . $this->img->getExt();
// Scale or resize the image
if (is_array($scl) && (isset($scl['w']) || isset($scl['h']))) {
if (isset($scl['w'])) {
$this->img->resizeToWidth($scl['w']);
} else {
if (isset($scl['h'])) {
$this->img->resizeToHeight($scl['h']);
}
}
} else {
if (is_float($scl)) {
$this->img->scale($scl);
} else {
if (is_int($scl)) {
$this->img->resize($scl);
} else {
throw new Exception('Error: The image scale value is not valid.');
}
}
}
// Save and clear the output buffer.
if ($this->img->getMime() == 'image/jpeg' || $this->img->getMime() == 'image/png' && $this->img->getColorMode() == 'RGB') {
$this->img->setQuality(90);
}
$this->img->save($this->scaledImage);
// Re-instantiate the newly scaled image object.
$this->img = new Gd($this->scaledImage);
}