/** * Get the MIME type of the image * * @return string|null */ public function getType() { if ($this->type) { return $this->type; } $this->stream->resetPointer(); switch ($this->stream->getChars(2)) { case "BM": return $this->type = 'bmp'; case "GI": return $this->type = 'gif'; case chr(0xff) . chr(0xd8): return $this->type = 'jpeg'; case chr(0x89) . 'P': return $this->type = 'png'; default: return null; } }
/** * Get the size of the image * * @return array */ public function getSize() { $this->stream->resetPointer(); return array_values($this->parseSize()); }