本文整理汇总了PHP中image类的典型用法代码示例。如果您正苦于以下问题:PHP image类的具体用法?PHP image怎么用?PHP image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param string $filename
* @param image $sourceImage
* @param rectangle $rectangle
*/
public function __construct($filename, $sourceImage, $rectangle)
{
parent::__construct($filename);
$this->setType($sourceImage->getType());
$this->fromArea($sourceImage, $rectangle);
$this->save();
}
示例2: nv_resize_crop_image
function nv_resize_crop_image($img_path, $width, $height, $module_name = '', $id = 0)
{
$new_img_path = '';
if (file_exists($img_path)) {
$imginfo = nv_is_image($img_path);
$basename = basename($img_path);
if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
$basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $id . '_\\1_' . $width . '-' . $height . '\\2', $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
$img_path = new image($img_path, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$thumb_width = $width;
$thumb_height = $height;
$maxwh = max($thumb_width, $thumb_height);
if ($img_path->fileinfo['width'] > $img_path->fileinfo['height']) {
$width = 0;
$height = $maxwh;
} else {
$width = $maxwh;
$height = 0;
}
$img_path->resizeXY($width, $height);
$img_path->cropFromCenter($thumb_width, $thumb_height);
$img_path->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
}
return $new_img_path;
}
示例3: index
public function index()
{
$database = new database();
$query = $database->query();
$images = new image($query);
$currentActive = $images->fetchCurrentActive();
$this->setVar('currentActive', $currentActive);
}
示例4: common
function common()
{
global $_G;
if (!defined('IN_DISCUZ') || empty($_GET['aid']) || empty($_GET['size']) || empty($_GET['key'])) {
header('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
exit;
}
$allowsize = array('960x960', '268x380', '266x698', '2000x2000');
if (!in_array($_GET['size'], $allowsize)) {
header('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
exit;
}
$nocache = !empty($_GET['nocache']) ? 1 : 0;
$daid = intval($_GET['aid']);
$type = !empty($_GET['type']) ? $_GET['type'] : 'fixwr';
list($w, $h) = explode('x', $_GET['size']);
$dw = intval($w);
$dh = intval($h);
$thumbfile = 'image/' . $daid . '_' . $dw . '_' . $dh . '.jpg';
$parse = parse_url($_G['setting']['attachurl']);
$attachurl = !isset($parse['host']) ? $_G['siteurl'] . $_G['setting']['attachurl'] : $_G['setting']['attachurl'];
if (!$nocache) {
if (file_exists($_G['setting']['attachdir'] . $thumbfile)) {
dheader('location: ' . $attachurl . $thumbfile);
}
}
define('NOROBOT', TRUE);
$id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
if (md5($id . '|' . $dw . '|' . $dh) != $_GET['key']) {
dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
}
if ($attach = C::t('forum_attachment_n')->fetch('aid:' . $daid, $daid, array(1, -1))) {
if (!$dw && !$dh && $attach['tid'] != $id) {
dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
}
dheader('Expires: ' . gmdate('D, d M Y H:i:s', TIMESTAMP + 3600) . ' GMT');
if ($attach['remote']) {
$filename = $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'];
} else {
$filename = $_G['setting']['attachdir'] . 'forum/' . $attach['attachment'];
}
require_once libfile('class/image');
$img = new image();
if ($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
if ($nocache) {
dheader('Content-Type: image');
@readfile($_G['setting']['attachdir'] . $thumbfile);
@unlink($_G['setting']['attachdir'] . $thumbfile);
} else {
dheader('location: ' . $attachurl . $thumbfile);
}
} else {
dheader('Content-Type: image');
@readfile($filename);
}
}
exit;
}
示例5: fromArea
/**
*
* @param image $image
* @param rectangle $rectangle
*/
public function fromArea($image, $sourceImage, $rectangle)
{
$image->init();
$sourceImage->init();
if (is_resource($sourceImage->meta)) {
$image->meta = imagecreatetruecolor($rectangle->getWidth(), $rectangle->getHeight());
$this->_thumbnail($sourceImage->meta, $image->meta, $rectangle);
}
}
示例6: nv_news_block_newscenter
function nv_news_block_newscenter($block_config)
{
global $module_data, $module_name, $module_file, $global_array_cat, $global_config, $lang_module, $db, $module_config, $module_info;
$module_name = 'news';
$module_data = 'news';
$xtpl = new XTemplate('block_newscenter.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/blocks');
$xtpl->assign('lang', $lang_module);
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
$db->sqlreset()->select('id, catid, publtime, title, alias, hometext, homeimgthumb, homeimgfile')->from(NV_PREFIXLANG . '_' . $module_data . '_rows')->where('status= 1')->order('publtime DESC')->limit(5);
$list = nv_db_cache($db->sql(), 'id', $module_name);
$i = 1;
foreach ($list as $row) {
$row['publtime'] = nv_date('m/d/Y', $row['publtime']);
$row['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$row['catid']]['alias'] . '/' . $row['alias'] . '-' . $row['id'] . $global_config['rewrite_exturl'];
$row['title0'] = nv_clean60(strip_tags($row['title']), $i == 1 ? 50 : 30);
$row['hometext'] = nv_clean60(strip_tags($row['hometext']), 260);
$image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
if ($row['homeimgfile'] != '' and file_exists($image)) {
if ($i == 1) {
$width = 570;
$height = 490;
} else {
$width = 270;
$height = 230;
}
$row['imgsource'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
$imginfo = nv_is_image($image);
$basename = basename($image);
if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
$basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $row['id'] . '_\\1_' . $width . '-' . $height . '\\2', $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
require_once NV_ROOTDIR . '/includes/class/image.class.php';
$_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$_image->cropFromCenter($width, $height);
$_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
} elseif (nv_is_url($row['homeimgfile'])) {
$row['imgsource'] = $row['homeimgfile'];
} elseif (!empty($module_config[$module_name]['show_no_image'])) {
$row['imgsource'] = NV_BASE_SITEURL . $module_config[$module_name]['show_no_image'];
} else {
$row['imgsource'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no-image.png';
}
$xtpl->assign('main' . $i, $row);
++$i;
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例7: fromArea
/**
*
* @param image $image
* @param rectangle $rectangle
*/
public function fromArea($image, $sourceImage, $rectangle)
{
$image->init();
$sourceImage->init();
if ($image->meta instanceof Imagick) {
if ($sourceImage->meta instanceof Imagick) {
$source = $sourceImage->meta->coalesceImages();
$this->_thumbnail($sourceImage->meta, $image->meta, $rectangle);
}
}
}
示例8: _unlikeImg
public function _unlikeImg($id)
{
$mem = new Memcache();
$mem->connect("127.0.0.1", 11211);
$like = $mem->get("f_" . $_SESSION['USERID']);
$like[$id] = NULL;
$mem->set("f_" . $_SESSION['USERID'], $like, 0, 0);
$recommender = recommender::getInstance();
$recommender->set_rating($_SESSION['USERID'], $id, 0);
echo json_encode("true");
$this->model->Del_By_ImageId($id);
$img = new image();
$img->removefromfavor($id);
}
示例9: common
function common()
{
global $_G;
if (empty($_G['uid'])) {
self::error('api_uploadavatar_unavailable_user');
}
if (empty($_FILES['Filedata'])) {
self::error('api_uploadavatar_unavailable_pic');
}
list($width, $height, $type, $attr) = getimagesize($_FILES['Filedata']['tmp_name']);
$imgtype = array(1 => '.gif', 2 => '.jpg', 3 => '.png');
$filetype = $imgtype[$type];
if (!$filetype) {
$filetype = '.jpg';
}
$avatarpath = $_G['setting']['attachdir'];
$tmpavatar = $avatarpath . './temp/upload' . $_G['uid'] . $filetype;
file_exists($tmpavatar) && @unlink($tmpavatar);
if (@copy($_FILES['Filedata']['tmp_name'], $tmpavatar) || @move_uploaded_file($_FILES['Filedata']['tmp_name'], $tmpavatar)) {
@unlink($_FILES['Filedata']['tmp_name']);
list($width, $height, $type, $attr) = getimagesize($tmpavatar);
if ($width < 10 || $height < 10 || $type == 4) {
@unlink($tmpavatar);
self::error('api_uploadavatar_unusable_image');
}
} else {
@unlink($_FILES['Filedata']['tmp_name']);
self::error('api_uploadavatar_service_unwritable');
}
$tmpavatarbig = './temp/upload' . $_G['uid'] . 'big' . $filetype;
$tmpavatarmiddle = './temp/upload' . $_G['uid'] . 'middle' . $filetype;
$tmpavatarsmall = './temp/upload' . $_G['uid'] . 'small' . $filetype;
$image = new image();
if ($image->Thumb($tmpavatar, $tmpavatarbig, 200, 250, 1) <= 0) {
//$image->error();
self::error('api_uploadavatar_unusable_image');
}
if ($image->Thumb($tmpavatar, $tmpavatarmiddle, 120, 120, 1) <= 0) {
//$image->error();
self::error('api_uploadavatar_unusable_image');
}
if ($image->Thumb($tmpavatar, $tmpavatarsmall, 48, 48, 2) <= 0) {
//$image->error();
self::error('api_uploadavatar_unusable_image');
}
$this->tmpavatar = $tmpavatar;
$this->tmpavatarbig = $avatarpath . $tmpavatarbig;
$this->tmpavatarmiddle = $avatarpath . $tmpavatarmiddle;
$this->tmpavatarsmall = $avatarpath . $tmpavatarsmall;
}
示例10: getDatabaseList
/**
* Gibt Dateiindex in Datenbank zurück
* @param int $limit
* @param int $offset
* @return array:\fpcm\model\files\image
*/
public function getDatabaseList($limit = false, $offset = false)
{
$where = '1=1' . $this->dbcon->orderBy(array('filetime DESC'));
if ($limit !== false && $offset !== false) {
$where .= ' ' . $this->dbcon->limitQuery($limit, $offset);
}
$images = $this->dbcon->fetch($this->dbcon->select($this->table, '*', $where), true);
$res = array();
foreach ($images as $image) {
$imageObj = new image('', '', '', false);
$imageObj->createFromDbObject($image);
$res[$image->filename] = $imageObj;
}
return $res;
}
示例11: doPOST
public function doPOST()
{
require DB_PATH . '/core/lib/image.php';
$img = new image($this->db);
try {
$img->upload($this->auth->authenticated());
redirect('view', $img->getentryid());
} catch (ImageException $e) {
if ($e->rollback) {
$img->rollback();
}
$_SESSION['upload_errors'][] = $e->getMessage();
redirect('upload');
}
}
示例12: _index
public function _index($album, $sub_tool = FALSE)
{
# this is a hack for allowed sub_tools only.
if (!is_object($album)) {
$album = ORM::factory('album')->where('fk_site', $this->site_id)->find($album);
if (!$album->loaded) {
return $this->wrap_tool('album error, please contact support', 'album', $album);
}
}
# set the thumbnail size USES TOGGLE:
$thumb_size = (isset($album->toggle) and is_numeric($album->toggle)) ? $album->toggle : 75;
# images
$images = json_decode($album->images);
if (NULL === $images or !is_array($images)) {
return $this->wrap_tool('no images.', 'album', $album);
}
foreach ($images as $image) {
$image->thumb = image::thumb($image->path, $thumb_size);
}
$display_view = empty($album->view) ? 'lightbox' : $album->view;
$primary = $this->{$display_view}($album, $images);
# add custom javascript;
$primary->global_readyJS(self::javascripts($album));
return $this->wrap_tool($primary, 'album', $album, $sub_tool);
}
示例13: getHtml
function getHtml($Recipient = null, $ZendMail = null)
{
$html = $this->html;
$data = $Recipient ? unserialize($Recipient->data) : array();
qg::fire('mail::gethtml', array('Mail' => $this, 'Recipient' => $Recipient, 'html' => &$html, 'data' => &$data, 'ZendMail' => $ZendMail));
if ($data) {
$T = new template($data);
$html = $T->renderMarker($html);
}
if ($ZendMail) {
// deprecated
preg_match_all("#<img.*?src=['\"]file://([^'\"]+)#i", $html, $matches);
$matches = array_unique($matches[1]);
if ($matches) {
$ZendMail->setType(Zend_Mime::MULTIPART_RELATED);
foreach ($matches as $key => $filename) {
if (!is_readable($filename) || !image::able($filename)) {
continue;
}
$at = $ZendMail->createAttachment(file_get_contents($filename));
$at->type = extensionToMime(preg_replace('/.*\\.([^.]+$)/', '$1', $filename));
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->id = 'i' . md5_file($filename);
$html = str_replace('file://' . $filename, 'cid:' . $at->id, $html);
trigger_error('error: auto inline images are deprecated!');
}
}
}
return $html;
}
示例14: manage
public function manage()
{
$album = $this->get_parent('album');
if ($_POST) {
if (NULL === json_decode($_POST['images'])) {
die('data is not properly formed JSON');
}
$album->images = $_POST['images'];
$album->save();
die('Album saved');
}
# images
$images = json_decode($album->images);
if (NULL === $images) {
$images = array();
}
foreach ($images as $image) {
$image->thumb = image::thumb($image->path);
}
$primary = new View('edit_album/manage');
$primary->album = $album;
$primary->images = $images;
$primary->img_path = $this->assets->assets_url();
die($primary);
}
示例15: resize
public function resize($width, $height = NULL)
{
if ($height === NULL) {
$height = $width;
}
return image::resize($this->file->getPath(), $this->file->getPath(), $width, $height);
}