protected function determineFormat()
{
if ($this->isDataStream === true) {
$this->format = 'STRING';
return;
}
$formatInfo = getimagesize($this->fileName);
// non-image files will return false
if ($formatInfo === false) {
if ($this->remoteImage) {
$this->triggerError('Could not determine format of remote image: ' . $this->fileName);
} else {
$this->triggerError('File is not a valid image: ' . $this->fileName);
}
// make sure we really stop execution
return;
}
$mimeType = isset($formatInfo['mime']) ? $formatInfo['mime'] : null;
switch ($mimeType) {
case 'image/gif':
$this->format = 'GIF';
break;
case 'image/jpeg':
$this->format = 'JPG';
break;
case 'image/png':
$this->format = 'PNG';
break;
default:
$this->triggerError('Image format not supported: ' . $mimeType);
}
}