/** * @return \Components\Io_Mimetype */ public function getMimetype() { if (null === $this->m_mimeType) { if ($this->exists()) { return $this->m_mimeType = Io_Mimetype::forFilePath($this->m_pathAsString); } return $this->m_mimeType = Io_Mimetype::forFileExtension($this->getExtension()); } return $this->m_mimeType; }
/** * @see \Components\Io_Image_Engine::save() \Components\Io_Image_Engine::save() * * @return \Components\Io_Image_Engine_Gd */ public function save($path_, Io_Mimetype $type_ = null) { if (null === $type_) { $type_ = Io_Mimetype::forFileExtension(Io::fileExtension($path_)); } if (null === $type_) { $type_ = Io_Mimetype::IMAGE_PNG(); } $typeName = $type_->name(); if (false === isset(self::$m_saveHandler[$typeName])) { throw new Exception_NotSupported('io/image/engine/gd', sprintf('Saving to image of requested type is not supported [%s].', $type_)); } $directory = dirname($path_); if (false === is_dir($directory)) { Io::directoryCreate($directory); } $saveHandler = self::$m_saveHandler[$typeName]; $saveHandler($this->m_resource, $path_); return $this; }