public function thumbnailAdapterCheckAction() { $instance = \Pimcore\Image::getInstance(); if ($instance instanceof \Pimcore\Image\Adapter\GD) { echo '<span style="color: red; font-weight: bold;padding: 10px;margin:0 0 20px 0;border:1px solid red;display:block;">' . $this->view->translate("important_use_imagick_pecl_extensions_for_best_results_gd_is_just_a_fallback_with_less_quality") . '</span>'; } exit; }
public function generateScreenshotAction() { $success = false; if ($this->getParam("id")) { $doc = Document::getById($this->getParam("id")); $url = Tool::getHostUrl() . $doc->getRealFullPath() . "?pimcore_preview=true"; $config = \Pimcore\Config::getSystemConfig(); if ($config->general->http_auth) { $username = $config->general->http_auth->username; $password = $config->general->http_auth->password; if ($username && $password) { $url = str_replace("://", "://" . $username . ":" . $password . "@", $url); } } $tmpFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/screenshot_tmp_" . $doc->getId() . ".png"; $file = PIMCORE_TEMPORARY_DIRECTORY . "/document-page-previews/document-page-screenshot-" . $doc->getId() . ".jpg"; $dir = dirname($file); if (!is_dir($dir)) { File::mkdir($dir); } try { if (\Pimcore\Image\HtmlToImage::convert($url, $tmpFile)) { $im = \Pimcore\Image::getInstance(); $im->load($tmpFile); $im->scaleByWidth(400); $im->save($file, "jpeg", 85); unlink($tmpFile); $success = true; } } catch (\Exception $e) { \Logger::error($e); } } $this->_helper->json(array("success" => $success)); }
/** * @return string */ public function getImage($width = null, $height = null) { if (!$width) { $width = 46; } if (!$height) { $height = 46; } $id = $this->getId(); $user = PIMCORE_WEBSITE_VAR . "/user-image/user-" . $id . ".png"; if (file_exists($user)) { $thumb = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/user-thumbnail-" . $id . ".png"; if (!file_exists($thumb)) { $image = \Pimcore\Image::getInstance(); $image->load($user); $image->cover($width, $height); $image->save($thumb, "png"); } return $thumb; } return PIMCORE_PATH . "/static/img/avatar.png"; }
/** * @static * @throws \Exception * @return null|\Pimcore\Image\Adapter */ public static function getImageTransformInstance() { try { $image = \Pimcore\Image::getInstance(); } catch (\Exception $e) { $image = null; } if (!$image instanceof \Pimcore\Image\Adapter) { throw new \Exception("Couldn't get instance of image tranform processor."); } return $image; }
margin: 0 auto; text-align: left; vertical-align: middle; width: 400px; } </style> </head> <body> <?php $thumbnail = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/image-version-preview-" . uniqid() . ".png"; $convert = \Pimcore\Image::getInstance(); $convert->load($this->asset->getTemporaryFile()); $convert->contain(500, 500); $convert->save($thumbnail, "png"); $dataUri = "data:image/png;base64," . base64_encode(file_get_contents($thumbnail)); unlink($thumbnail); ?> <table id="wrapper" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="center"> <img src="<?php echo $dataUri; ?> "/> </td>