public static function getInstance() { if (!self::$instance) { self::$instance = new ImageCreator(); } return self::$instance; }
public static function sendImg() { if (!isset($_GET['purpose']) || !is_numeric($_GET['purpose'])) { header($_SERVER['SERVER_PROTOCOL'] . ' Internal Server Error'); header('X-Error_message: Invalid script parameters'); exit(1); } $purpose = htmlentities($_GET['purpose']); if (!isset($_GET['filename']) || $_GET['filename'] == "") { header('content-type: image/jpeg'); $imgdata = ImageCreator::getInstance()->getImageForPurpose('notfound.jpg', $purpose, dirname(__FILE__) . '/../img'); echo $imgdata; exit; } $filename = htmlentities($_GET['filename']); try { $imgdata = ImageCreator::getInstance()->getImageForPurpose($filename, $purpose, DATA_DIR, CACHE_DIR); header('content-type: image/jpeg'); echo $imgdata; } catch (ImgNotExistsException $e) { header('content-type: image/jpeg'); $imgdata = ImageCreator::getInstance()->getImageForPurpose('notfound.jpg', $purpose, dirname(__FILE__) . '/../img'); echo $imgdata; } catch (ImgProcException $e) { header($_SERVER['SERVER_PROTOCOL'] . ' Internal Server Error'); header('X-Error_message: ' . $e->getMessage()); } }
protected function internalImageHasTextConfiguration($filename) { $imgCfg = ImageCreator::getInstance()->getImageConfiguration($filename); if ($imgCfg) { return true; } else { return false; } }
protected function exportImageFile($filename) { $imgData = ImageCreator::getInstance()->getImageForPurpose($filename, ImagePurpose::HD, $this->mediaDirectory); $outputFilename = $this->outputDirectory . '/' . $filename; self::saveToFile($outputFilename, $imgData); }
protected function loadImgConfiguration() { if ($this->textConfigLoaded) { return; } $this->textConfigLoaded = true; $imgConfig = ImageCreator::getInstance()->getImageConfiguration($this->getImageFilename()); if ($imgConfig == null) { return; } $textConfig = $imgConfig['text']; if ($textConfig) { $this->imageTextConfigAvailable = true; $this->imageTextColor = $textConfig['color']; $this->imageTextFontFace = new JsonFontFace(); $this->imageTextFontFace->setFamily($textConfig['font']); $this->imageTextFontFace->setSize($textConfig['size']); $this->imageTextFontFace->setBold($textConfig['bold']); $this->imageTextFontFace->setItalic($textConfig['italic']); $this->imageTextFontFace->setUnderline($textConfig['underline']); $this->imageTextFontFace->setOverstrike($textConfig['overstrike']); $this->imageTextPosition = new JsonXYPosition(); $this->imageTextPosition->setX($textConfig['posX']); $this->imageTextPosition->setY($textConfig['posY']); } }