本文整理汇总了PHP中Image::display方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::display方法的具体用法?PHP Image::display怎么用?PHP Image::display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gernate
/**
* gernate
* 生成验证码
* @access public
* @return void
*/
public function gernate()
{
$image = new Image();
$valid = $image->imageValidate(64, 21, $_SERVER['ENV']['params']['VALID_CODE_LENGTH'], $_SERVER['ENV']['params']['VALID_CODE_TYPE'], '#3e3e3e', '#B6B6B6');
$this->ci->session->set_userdata('vidfy', $valid);
$image->display();
die;
}
示例2: resizeImage
function resizeImage()
{
//lay duong dan file duoc request
$request = $_SERVER['REQUEST_URI'];
//lay ten file
$tmp_request = explode('/', $request);
$case = count($tmp_request);
$image_name = $tmp_request[$case - 1];
//type resize
$resize_type = $tmp_request[$case - 2];
//echo $image_name;
$resource_img = get_picture_dir($image_name) . '/' . $image_name;
$resource_img = '..' . $resource_img;
if (!file_exists($resource_img)) {
error_404_document();
}
//echo file_get_contents($resource_img);exit();
$images = new Image($resource_img);
$imageinfo = $images->getImageInfo();
if ($imageinfo['height'] == null || $imageinfo['height'] == 0) {
error_404_document();
}
//kich thuoc resize
$array_resize = array('large' => array(480, 360), 'medium' => array(240, 180), 'medium2' => array(145, 95), 'small' => array(106, 80), 'thumb' => array(50, 50), 'mobile' => array(640, 400), 'mobile_medium' => array(320, 200), 'mobile_small' => array(120, 75), 'mobile_low' => array(640, 400, 30), 'mobile_medium_low' => array(320, 200, 30), 'mobile_small_low' => array(120, 75, 30));
if (!isset($array_resize[$resize_type])) {
error_404_document();
}
//image name file no extension
$filesavename = explode('.', $image_name);
$count3 = count($filesavename);
if ($count3 > 1) {
unset($filesavename[$count3 - 1]);
}
$filesavename = implode('.', $filesavename);
$pathsave = '..' . get_picture_dir($image_name, $resize_type);
//nếu thư mục ảnh không tồn tại thì tạo mới
if (!file_exists($pathsave)) {
mkdir($pathsave, 0755, 1);
}
//echo $pathsave;die();
//kich thuoc resize ok -> tao file voi kich thuoc phu hop
$r_width = $array_resize[$resize_type][0];
$r_height = $array_resize[$resize_type][1];
if (isset($array_resize[$resize_type][2])) {
$r_quality = $array_resize[$resize_type][2];
} else {
$r_quality = 100;
}
if ($resize_type == 'organic') {
$images->resize($r_width, $r_height, 'fit', 'c', 'c', $r_quality);
} else {
$images->resize($r_width, $r_height, 'crop', 'c', 'c', $r_quality);
}
$images->save($filesavename, $pathsave);
header("HTTP/1.0 200 OK");
$images->display();
}
示例3: thumbnail
function thumbnail()
{
$video = new Video($_GET['id']);
$img = Config::get("basedir") . "/public/video/" . $video->user_id . "/" . $video->id . "/thumb" . $video->thumb . ".png";
$thumb = str_replace(".png", "-" . $_GET['width'] . "x" . $_GET['height'] . ".png", $img);
header("Pragma: public");
//get the last-modified-date of this very file
$lastModified = filemtime($img);
//get a unique hash of this file (etag)
$etagFile = md5_file($img);
$ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
$etagHeader = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false;
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", date("U") + 60 * 60 * 24) . " GMT");
header("Etag: {$etagFile}");
header('Cache-Control: public');
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) {
header("HTTP/1.1 304 Not Modified");
exit;
}
if (file_exists($thumb)) {
header("Content-Type: image/png");
echo file_get_contents($thumb);
die;
}
$image = new Image($img);
if (isset($_GET['width']) && is_numeric($_GET['width']) && isset($_GET['height']) && is_numeric($_GET['height'])) {
$image->resize($_GET['width'], $_GET['height'], "crop");
$img = str_replace(".png", "-" . $_GET['width'] . "x" . $_GET['height'] . ".png", $img);
$parts = pathinfo($img);
$image->setPathToTempFiles("/tmp");
$image->save($parts['filename'], $parts['dirname'], $parts['extension']);
}
$image->display();
die;
}
示例4: Image
<?php
include '../class.Images.php';
//Create a new object, send relative or absolut path to your image
$image = new Image('pngWithTransparency.png');
//We can rotate the image
#$image->rotate(90);
//and we can resize and crop it to have a nice thumbnail
$image->resize(150, 150, 'crop');
//lets see what we have!
$image->display();
示例5: elseif
// We resize to a preview size if needed
$image->resizemax('800');
$resize = true;
}
// We change the image format if needed
if (isset($_GET['format']) && $image->is_supported($_GET['format'])) {
$image->convert($_GET['format']);
} elseif (isset($_GET['thumbnail']) && $image->format != 'svg') {
// Or, if no format is explicitely specified and a thumbnail has to be created, we convert the image to the $thumbnail_format
if ($image->format == 'png') {
$thumbnail_format = 'png';
// preserves transparency
}
$image->convert($thumbnail_format);
}
$content = $image->display();
// If the new image creating has failed, fallback to an icon
if (!isset($_GET['icon']) && ($content === null || $content === false)) {
$tryIconFallback = true;
$_GET['icon'] = 'y';
$_GET['max'] = 32;
} else {
$info['filetype'] = $image->get_mimetype();
}
}
} while ($tryIconFallback);
}
if (strpos($info['filetype'], 'image/svg') !== false) {
$info['filetype'] = 'image/svg+xml';
$content = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' . "\n" . $content;
}
示例6: ProcessImage
/**
* Proccess Image
* Generate a image the first time is requested to be served by apache later
* To take advantage of this service, you should use Apache Header module width Header set Cache-Control
* @return void
*/
public static function ProcessImage()
{
$id = Util::getvalue('id');
$args = Util::getvalue('params');
$ext = Util::getvalue('ext');
$options = array('id' => $id, 'width' => false, 'height' => false, 'quality' => false, 'type' => 'resize');
// Parametro Ancho
if (preg_match('/w([0-9]+)/i', $args, $outputWidth)) {
$options['width'] = $outputWidth[1];
}
// Parametro Alto
if (preg_match('/h([0-9]+)/i', $args, $outputHeight)) {
$options['height'] = $outputHeight[1];
}
// Parametro calidad
if (preg_match('/q(100|\\d{1,2})/i', $args, $outputHeight)) {
$options['quality'] = $outputHeight[1];
}
// Type Crop / Resize
$arr = explode('.', $args);
if (strpos($arr[0], 'c') !== false) {
$options['type'] = 'crop';
}
// Extension del archivo solicitado
$fileType = $ext ? strtolower($ext) : 'jpg';
$fileType = substr($fileType, 0, 3);
$fileType = $fileType == 'jpe' ? 'jpg' : $fileType;
$fileType = '.' . $fileType;
// Ruta del a imagen origina en disco
$sourceOpt = array('module' => 'image', 'folderoption' => 'target');
$sourceDir = PathManager::GetContentTargetPath($sourceOpt);
$sourcePath = PathManager::GetDirectoryFromId($sourceDir, $id);
$source = $sourcePath . '/' . $id . $fileType;
$imageDir = PathManager::GetApplicationPath() . Configuration::Query('/configuration/images_bucket')->item(0)->nodeValue;
if (!is_dir($imageDir)) {
mkdir($imageDir, 0777);
}
$imagePath = PathManager::GetDirectoryFromId($imageDir, $id);
$image = $imagePath . '/' . $id;
// El nombre del archivo contendrá los parametros para ser servida de manera estatica
if ($options['width']) {
$image .= 'w' . $options['width'];
}
if ($options['height']) {
$image .= 'h' . $options['height'];
}
if ($options['quality'] !== false) {
$image .= 'q' . $options['quality'];
}
if ($options['type'] == 'crop') {
$image .= 'c';
}
if (!file_exists($source)) {
$source = PathManager::GetApplicationPath() . '/content/not-found' . $fileType;
}
list($sourceWidth, $sourceHeight) = getimagesize($source);
/*
Si no esta definido el ancho o el alto
debemos asignar limites por defecto para la generación de la imagen
*/
$options['width'] = $options['width'] ? $options['width'] : $sourceWidth;
$options['height'] = $options['height'] ? $options['height'] : $sourceHeight;
// Generar la imagen
$img = new Image();
$img->load($source);
$img->{$options}['type']($options['width'], $options['height']);
/*
Guardar la imagen en disco
el próximo pedido será servido estáticamente por apache
*/
$quality = $options['quality'] !== false ? $options['quality'] : '80';
$img->save($image, $quality);
/* Mostrar la imagen */
$img->display();
}
示例7: __construct
{
echo "Display {$this->filename}\n";
}
}
class ProxyImage implements ImageInterface
{
protected $image;
public function __construct($filename)
{
$this->filename = $filename;
}
public function display()
{
if (null === $this->image) {
$this->image = new Image($this->filename);
}
return $this->image->display();
}
}
// Usage example
$filename = 'test.png';
$image1 = new Image($filename);
// loading necessary
echo $image1->display();
// loading unnecessary
$image2 = new ProxyImage($filename);
// loading unnecessary
echo $image2->display();
// loading necessary
echo $image2->display();
// loading unnecessary
示例8: display_image
public function display_image()
{
// Make sure code has access to my image class (temp solution)
#require(APP_PATH.'/libraries/Image.php');
#echo "You are looking at test1.";
#echo APP_PATH."<br>";
#echo DOC_ROOT."<br>";
// Once we have access, we instantiate an object from that class
// and pass the parameter to the construct
$imageObj = new Image('http://placekitten.com/1000/1000');
// Then we have access to all the methods within that object
// and we can point to the methods in that class
$imageObj->resize(500, 500);
$imageObj->display();
}
示例9: test1
public function test1()
{
#require(APP_PATH.'/libraries/image.php');
#echo "testing!";
$imgObj = new Image('images/placeholder.png');
$imgObj->resize(200, 200);
$imgObj->display();
}
示例10: icon
/**
* @param $extension
* @param int $x
* @param int $y
* @return bool|null|string
*/
function icon($extension, $x = 0, $y = 0)
{
$keep_original = $x == 0 && $y == 0;
$format = $this->get_icon_default_format();
$icon_format = '';
if (!$keep_original) {
$icon_format = $format;
if ($this->is_supported('png')) {
$format = 'png';
} elseif ($this->is_supported('svg')) {
$format = 'svg';
} else {
return false;
}
}
$name = "lib/images/icons/{$extension}.{$format}";
if (!file_exists($name)) {
$name = "lib/images/icons/unknown.{$format}";
}
if (!$keep_original && $format != 'svg') {
$icon = new Image($name, true, $format);
if ($format != $icon_format) {
$icon->convert($icon_format);
}
$icon->resize($x, $y);
return $icon->display();
} else {
return $this->get_from_file($name);
}
}
示例11: display_image
public function display_image()
{
// Make sure code has access to my image class (temp solution)
require APP_PATH . '/libraries/Image.php';
#echo "You are looking at test1.";
#echo APP_PATH."<br>";
#echo DOC_ROOT."<br>";
// Once we have access, we instantiate an object from that class
// and pass the parameter to the construct
$imageObj = new Image('http://placekitten.com/1000/1000');
// Then we have access to all the methods within that object
// and we can point to the methods in that class
$imageObj->resize(500, 500);
$imageObj->display();
/* from A's section 10/22
$imageObj = new Image('img/kitten.jpg');
$imageObj->resize(500,500);
$image_class = get_class($imageObj);
$reflector = new ReflectionClass($image_class);
$fn = $reflector->getFileName();
echo dirname($fn);
*/
}
示例12: header
die;
}
// if blank then die, otherwise we offer to download strangeness
// this also catches invalid id's
if (!$storedData) {
die;
}
$type = $storedData["image_type"];
$data =& $storedData["image_data"];
header("Content-type: " . $type);
if (!empty($_REQUEST['width'])) {
require_once 'lib/images/images.php';
$image = new Image($data);
if ($image->get_width() > $_REQUEST['width']) {
$image->resize($_REQUEST['width'], 0);
$data = $image->display();
}
if (empty($data)) {
die;
}
}
if ($useCache && $data) {
$fp = fopen($temporaryFile, "wb");
fputs($fp, $data);
fclose($fp);
}
echo $data;
} else {
$size = getimagesize($temporaryFile);
header("Content-type: " . $size['mime']);
readfile($temporaryFile);
示例13: registry
}
spl_autoload_register('autoLoader');
global $registry;
App::setUrl();
DEFINE('DESIGNPATH', App::getURLForDesignDirectory());
DEFINE('URL', App::getHost(1) . '/' . LOCAL_CATALOG);
$registry = new registry();
if (!@(include_once ROOTPATH . 'config' . DS . 'settings.php')) {
include ROOTPATH . 'includes' . DS . 'install.php';
die;
}
$registry->router = new Router($registry);
try {
$registry->db = Db::getInstance($Config['database']);
} catch (Exception $e) {
echo $e->getMessage();
die;
}
$registry->session = new session($registry);
$registry->loader = new Loader($registry);
$registry->core = new Core($registry);
$layer = $registry->loader->getCurrentLayer();
$path = ROOTPATH . 'design' . DS . '_gallery' . DS . '_orginal' . DS . $_GET['image'];
if (is_file($path)) {
$objImage = new Image($path);
if (isset($layer['watermark']) && !is_null($layer['watermark']) && strlen($layer['watermark']) > 4) {
$watermark = new Image(ROOTPATH . 'design/_images_frontend/core/logos/' . $layer['watermark']);
$objImage->watermark($watermark);
}
$objImage->display();
}
示例14: Image
<ul>
<?php
$config['thumb_width'] = 200;
$img = new Image($config);
foreach ($obj_array as $index => $m) {
$img->init_thumb($m);
?>
<li class="list-item clear">
<a class="fancybox-alt" title="<?php
echo $m->title;
?>
" href="<?php
echo $img->orig_src;
?>
"><?php
$img->display();
?>
</a>
<div class="list-content">
<h2><?php
echo $img->title;
?>
</h2>
<p class="technology"><?php
echo $m->technology;
?>
</p>
<p class="description"><?php
echo $m->description;
?>
</p>
示例15: resizeImage
private function resizeImage($image_temp)
{
$image = new Image($image_temp);
list($width, $height) = getimagesize($image_temp);
//640 * 480
if ($width + $height > 1120) {
if ($width > $height) {
$width = $image->getWidth() * 640 / $image->getHeight();
$image->resize(640, $width, 'fit');
} else {
$height = $image->getHeight() * 480 / $image->getWidth();
$image->resize(640, $height, 'fit');
}
}
$image->display();
}