本文整理汇总了PHP中Image::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::render方法的具体用法?PHP Image::render怎么用?PHP Image::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderInternal
/**
* Render the given element
*
* @return array
*/
public function renderInternal()
{
$image = new Image();
if (!($this->contentObject->data['imageorient'] & 24)) {
$lines = $image->render($this->contentObject, $this->configuration);
$lines[] = '';
}
$lines[] = $this->breakContent(strip_tags($this->parseBody($this->contentObject->data['bodytext'])));
if ($this->contentObject->data['imageorient'] & 24) {
$lines[] = '';
$lines = array_merge($lines, $image->render($this->contentObject, $this->configuration));
}
return $lines;
}
示例2: render
/**
* Renders image
*
* @param int $quality
* @throws Imagify_Exception
* @return string
*/
public function render($quality = 80)
{
if (!isset($this->_image)) {
throw new Imagify_Exception('Image is not yet created to render it');
}
echo $this->_image->render(null, $quality);
}
示例3: makeThumbnail
public function makeThumbnail($id, $field, $w, $h, $crop = false, $enlarge = false)
{
$path = $this->getImagePath($id, $field);
// \helpers\Debug::prePrintR($path);
if (!empty($path)) {
$tn = ($crop ? 'cr' : '') . ($enlarge ? 'en' : '');
$cache = str_replace($this->tableMeta->get('table'), $this->tableMeta->get('table') . '/tmp/' . $tn . $w, $path);
if (file_exists($cache)) {
$ext = pathinfo($path, PATHINFO_EXTENSION);
$img = new \Image($cache);
echo $img->render($ext);
return true;
} elseif (file_exists($path)) {
// Создаём и сохраняем миниатюру
$img = new \Image($path);
$img->resize($w, $h, $crop, $enlarge);
$dir = $this->makeDirStructure($id, $tn . $w);
if ($dir) {
$ext = pathinfo($path, PATHINFO_EXTENSION);
$f3 = \Base::instance();
$res = $f3->write($dir . $tn . $field . '.' . $ext, $img->dump());
echo $img->render($ext);
return true;
}
}
}
return false;
}
示例4: captchaF3
public static function captchaF3()
{
$img = new \Image();
$img->captcha('template/captchaFonts/Browning.ttf', 16, 5, 'SESSION.captcha');
$_SESSION['captcha'] = password_hash($_SESSION['captcha'], PASSWORD_DEFAULT);
ob_start();
$img->render();
$image_data = ob_get_contents();
ob_end_clean();
echo base64_encode($image_data);
}
示例5: photo_handler
public function photo_handler($f3)
{
/*echo $f3->get('PARAMS.certi_type') . "<br>";
echo $f3->get('PARAMS.category') . "<br>";
echo $f3->get('PARAMS.filename') . "<br>";*/
$temp = $f3->get('certi_folder');
//echo $temp[$f3->get('PARAMS.certi_type')];
$docpath = DOCROOT . "/";
$docpath .= $f3->get("doc_folder_name") . "/";
$docpath .= $temp[$f3->get('PARAMS.certi_type')] . "/";
$docpath .= $f3->get('PARAMS.category') . "/";
$file = $f3->get('PARAMS.filename');
$file = setEncryptDecrption($file, false);
$img = new Image($file, FALSE, $docpath);
$img->render();
exit;
}
示例6: thumbnail
function thumbnail($file, $width, $height, $crop = true, $enlarge = true)
{
$domain = $this->f3->get("domain");
//test_array($file);
$thumb = explode(".", $file);
$thumbExt = $thumb[count($thumb) - 1];
$thumb = str_replace("." . $thumbExt, "_thumb." . $thumbExt, $file);
$cfg = $this->f3->get("cfg");
$folder = $cfg['media'];
$path = $folder;
$path = $this->f3->fixslashes($path);
$path = str_replace("//", "/", $path);
//test_array($file);
$folder = "";
// test_array($file);
header('Pragma: public');
header('Cache-Control: max-age=86400');
header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 86400));
$thumb = new Image($file, false, $path);
$thumb->resize($width, $height, $crop, $enlarge);
$thumb->render('jpeg');
$showthumb = true;
}
示例7: die
if ($crop) {
$image->scaleSpace($width, $height, $_REQUEST['bg']);
} else {
$image->scale($width, $height, $_REQUEST['bg']);
}
$image->renderOutputHeader($actual_name);
$image->render($cacheFile);
print file_get_contents($cacheFile);
} else {
if (!($image = new Image($cacheFile, $quality))) {
die("<h1>Symphony Fatal Error</h1><p>Error opening cached image<hr /><em>" . $_SERVER['SERVER_SIGNATURE'] . "</em>");
}
$image->renderOutputHeader($actual_name);
$image->render();
}
} else {
if (!($image = new Image($file, $quality))) {
die("<h1>Symphony Fatal Error</h1><p>Error creating Image in memory<hr /><em>" . $_SERVER['SERVER_SIGNATURE'] . "</em>");
}
if ($crop) {
$image->scaleSpace($width, $height, $_REQUEST['bg']);
} else {
$image->scale($width, $height, $_REQUEST['bg']);
}
$image->renderOutputHeader($actual_name);
$image->render();
}
$image->close();
unset($image);
exit;
}
示例8: file_attach
function file_attach($id)
{
$con = connection();
$date = date("Y-m-d H:i:s");
$max_file_size = 4194304;
if (!$_FILES['userfile']['name'][0] == '') {
if (isset($_FILES['userfile']['tmp_name'])) {
for ($i = 0; $i < count($_FILES['userfile']['tmp_name']); $i++) {
//$allowed_filetypes = array('.pdf','.txt','.word','.doc','.xls','.docx','.ppt','.xlsx');
$allowed_filetypes = array('.png', '.jpeg', '.jpg');
$final_path = "../attachment/";
$final_path_thumb = "../attachment/thumb";
$filename = $_FILES['userfile']['name'][$i];
$ext = substr($filename, strpos($filename, '.'), strlen($filename) - 1);
if (!in_array($ext, $allowed_filetypes)) {
die('The file that you are trying to upload is not allowed.');
}
if (!is_uploaded_file($_FILES['userfile']['tmp_name'][$i])) {
$message = 'No file uploaded';
}
if ($_FILES['userfile']['size'][$i] > $max_file_size) {
$message = "File size exceeds {$max_file_size} limit";
}
$new_filename = md5(date("Y-m-d H:i:s")) . rand() . $ext;
$p = $final_path . $new_filename;
//echo $_FILES['userfile']['tmp_name'][$i];
//echo "<br>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $p)) {
require_once 'image.class.php';
$image = new Image($p);
$image->destination = $final_path_thumb . '/' . $new_filename;
//echo $final_path_thumb.'/'.$new_filename;
$image->constraint = 'w';
$image->size = 220;
$image->quality = 100;
$image->render();
if (store_file($id, $new_filename)) {
return true;
} else {
return false;
}
//
} else {
return false;
}
}
}
}
}
示例9: _do_watermark
protected function _do_watermark(Image $watermark, $offset_x, $offset_y, $opacity)
{
if (!Image_GD::$_bundled) {
throw new Kohana_Exception('This method requires :function, which is only available in the bundled version of GD', array(':function' => 'imagelayereffect'));
}
// Loads image if not yet loaded
$this->_load_image();
// Create the watermark image resource
$overlay = imagecreatefromstring($watermark->render());
// Get the width and height of the watermark
$width = imagesx($overlay);
$height = imagesy($overlay);
if ($opacity < 100) {
// Convert an opacity range of 0-100 to 127-0
$opacity = round(abs($opacity * 127 / 100 - 127));
// Allocate transparent white
$color = imagecolorallocatealpha($overlay, 255, 255, 255, $opacity);
// The transparent image will overlay the watermark
imagelayereffect($overlay, IMG_EFFECT_OVERLAY);
// Fill the background with transparent white
imagefilledrectangle($overlay, 0, 0, $width, $height, $color);
}
// Alpha blending must be enabled on the background!
imagealphablending($this->_image, TRUE);
if (imagecopy($this->_image, $overlay, $offset_x, $offset_y, 0, 0, $width, $height)) {
// Destroy the overlay image
imagedestroy($overlay);
}
}
示例10: _do_watermark
protected function _do_watermark(Image $watermark, $offset_x, $offset_y, $opacity)
{
// Create the watermark image resource
$overlay = imagecreatefromstring($watermark->render());
// Get the width and height of the watermark
$width = imagesx($overlay);
$height = imagesy($overlay);
if ($opacity < 100) {
// Convert an opacity range of 0-100 to 127-0
$opacity = round(abs($opacity * 127 / 100 - 127));
// Allocate transparent white
$color = imagecolorallocatealpha($overlay, 255, 255, 255, $opacity);
// The transparent image will overlay the watermark
imagelayereffect($overlay, IMG_EFFECT_OVERLAY);
// Fill the background with transparent white
imagefilledrectangle($overlay, 0, 0, $width, $height, $color);
}
// Alpha blending must be enabled on the background!
imagealphablending($this->_image, TRUE);
if (imagecopy($this->_image, $overlay, $offset_x, $offset_y, 0, 0, $width, $height)) {
// Destroy the overlay image
imagedestroy($overlay);
}
}
示例11: actionImage
public function actionImage()
{
$file_name = Yii::app()->request->getParam('path');
$tmp_path = Yii::app()->runtimePath;
$new_filename = $tmp_path . '/' . $file_name;
Yii::import('application.extensions.image.Image');
$image_base = new Image($new_filename);
$image_base->render();
}
示例12: _do_watermark
protected function _do_watermark(Image $image, $offset_x, $offset_y, $opacity)
{
$filein = isset($this->filetmp) ? $this->filetmp : $this->file;
// Create temporary file to store the watermark image
$watermark = tempnam(Upload::$default_directory, '');
$fp = fopen($watermark, 'wb');
if (!fwrite($fp, $image->render())) {
return FALSE;
}
// Merge watermark with image
$fileout = tempnam(Upload::$default_directory, '');
$command = Image_ImageMagick::get_command('composite');
$command .= ' -quality 100 -dissolve ' . escapeshellarg($opacity) . '% -geometry +' . escapeshellarg($offset_x) . '+' . escapeshellarg($offset_y);
$command .= ' ' . escapeshellarg($watermark) . ' ' . escapeshellarg($filein);
$command .= ' ' . escapeshellarg('PNG:' . $fileout);
//save as PNG to keep transparency
exec($command, $response, $status);
if ($status) {
return FALSE;
}
// Delete temp files and close handlers
fclose($fp);
unlink($watermark);
// Delete old tmp file if exist
if (isset($this->filetmp) && file_exists($this->filetmp)) {
unlink($this->filetmp);
}
// Update image data
$this->filetmp = $fileout;
return TRUE;
}
示例13: render
function render($type = 'jpg', $dst_file = '')
{
return parent::render($type, $dst_file);
}
示例14: avatar
/**
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function avatar($f3, $params)
{
// Ensure proper content-type for JPEG images
if ($params["format"] == "jpg") {
$params["format"] = "jpeg";
}
$user = new \Model\User();
$user->load($params["id"]);
if ($user->avatar_filename && is_file("uploads/avatars/" . $user->avatar_filename)) {
// Use local file
$img = new \Image($user->avatar_filename, null, "uploads/avatars/");
$img->resize($params["size"], $params["size"]);
// Render and output image
header("Content-type: image/" . $params["format"]);
$img->render($params["format"]);
} else {
// Send user to Gravatar
$f3->reroute($f3->get("SCHEME") . ":" . \Helper\View::instance()->gravatar($user->email, $params["size"]), true);
}
}
示例15: _do_watermark
/**
* Execute a watermarking.
*
* @param Image $image watermarking Image
* @param integer $offset_x offset from the left
* @param integer $offset_y offset from the top
* @param integer $opacity opacity of watermark
* @return void
*/
protected function _do_watermark(Image $watermark, $offset_x, $offset_y, $opacity)
{
if (empty(GD::$_available_functions[GD::IMAGELAYEREFFECT])) {
die('This method requires "imagelayereffect", which is only available in the bundled version of GD');
}
// Loads image if not yet loaded
$this->_load_image();
// Create the watermark image resource
$overlay = imagecreatefromstring($watermark->render());
imagesavealpha($overlay, TRUE);
// Get the width and height of the watermark
$width = imagesx($overlay);
$height = imagesy($overlay);
if ($opacity < 100) {
// Convert an opacity range of 0-100 to 127-0
$opacity = round(abs($opacity * 127 / 100 - 127));
// Allocate transparent gray
$color = imagecolorallocatealpha($overlay, 127, 127, 127, $opacity);
// The transparent image will overlay the watermark
imagelayereffect($overlay, IMG_EFFECT_OVERLAY);
// Fill the background with the transparent color
imagefilledrectangle($overlay, 0, 0, $width, $height, $color);
}
// Alpha blending must be enabled on the background!
imagealphablending($this->_image, TRUE);
if (imagecopy($this->_image, $overlay, $offset_x, $offset_y, 0, 0, $width, $height)) {
// Destroy the overlay image
imagedestroy($overlay);
}
}