本文整理汇总了PHP中resize_thumb函数的典型用法代码示例。如果您正苦于以下问题:PHP resize_thumb函数的具体用法?PHP resize_thumb怎么用?PHP resize_thumb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resize_thumb函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pic_cutOp
/**
* 图片裁剪
*
*/
public function pic_cutOp()
{
Language::read('admin_common');
$lang = Language::getLangContent();
import('function.thumb');
if (chksubmit()) {
$thumb_width = $_POST['x'];
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
$scale = $thumb_width / $w;
$src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
if (strpos($src, '..') !== false || strpos($src, BASE_UPLOAD_PATH) !== 0) {
exit;
}
if (!empty($_POST['filename'])) {
// $save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename'];
$save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']);
} else {
$save_file2 = str_replace('_small.', '_sm.', $src);
}
$cropped = resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
@unlink($src);
$pathinfo = pathinfo($save_file2);
exit($pathinfo['basename']);
}
$save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
$_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
Tpl::output('height', get_height($save_file));
Tpl::output('width', get_width($save_file));
Tpl::showpage('common.pic_cut', 'null_layout');
}
示例2: pic_cutOp
/**
* 图片裁剪
*
*/
public function pic_cutOp()
{
import('function.thumb');
if (chksubmit()) {
$thumb_width = $_POST['x'];
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
$scale = $thumb_width / $w;
$src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
$save_file2 = str_replace('_small.', '_sm.', $src);
$cropped = resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
@unlink($src);
$pathinfo = pathinfo($save_file2);
exit($pathinfo['basename']);
} else {
Language::read('cut');
$lang = Language::getLangContent();
}
$save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
$_GET['x'] = intval($_GET['x']) > 50 && $_GET['x'] < 400 ? $_GET['x'] : 200;
$_GET['y'] = intval($_GET['y']) > 50 && $_GET['y'] < 400 ? $_GET['y'] : 200;
$_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
Tpl::output('height', get_height($save_file));
Tpl::output('width', get_width($save_file));
Tpl::showpage('cut', 'null_layout');
}
示例3: pic_cut
/**
* 图片裁剪
*
*/
public function pic_cut()
{
//import('function.thumb');
if (chksubmit()) {
$thumb_width = $_POST['x'];
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
$scale = $thumb_width / $w;
$src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
if (!empty($_POST['filename'])) {
// $save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename'];
$save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']);
} else {
$save_file2 = str_replace('_small.', '_sm.', $src);
}
$cropped = resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
@unlink($src);
$pathinfo = pathinfo($save_file2);
//<<<<<<
//exit($pathinfo['basename']);
//<<<<<<
//>>>>>>
$file = $pathinfo['basename'];
fileServiceConvert($file);
exit($file);
//>>>>>>
}
$save_file = str_ireplace(UP_IMAGE, BASE_UPLOAD_PATH, $_GET['url']);
$_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
$this->assign('height', 100);
$this->assign('width', 200);
//Tpl::showpage('common.pic_cut','null_layout');
$this->display('html/common.pic_cut');
}
示例4: cutOp
/**
* 裁剪
*
*/
public function cutOp()
{
if (chksubmit()) {
$thumb_width = 120;
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
$scale = $thumb_width / $w;
$_POST['newfile'] = str_replace('..', '', $_POST['newfile']);
if (strpos($_POST['newfile'], "avatar_{$_SESSION['member_id']}_new.") !== 0) {
redirect('index.php?act=home&op=avatar');
}
$src = BASE_UPLOAD_PATH . DS . ATTACH_AVATAR . DS . $_POST['newfile'];
$avatarfile = BASE_UPLOAD_PATH . DS . ATTACH_AVATAR . DS . "avatar_{$_SESSION['member_id']}.jpg";
import('function.thumb');
$cropped = resize_thumb($avatarfile, $src, $w, $h, $x1, $y1, $scale);
@unlink($src);
Model()->table('member')->where(array('member_id' => $_SESSION['member_id']))->update(array('member_avatar' => 'avatar_' . $_SESSION['member_id'] . '.jpg'));
$_SESSION['avatar'] = 'avatar_' . $_SESSION['member_id'] . '.jpg';
redirect('index.php?act=home&op=avatar');
}
}
示例5: cutOp
/**
* 图片裁剪
*/
public function cutOp()
{
if (chksubmit()) {
$thumb_width = 120;
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
$scale = $thumb_width / $w;
$_POST['newfile'] = str_replace('..', '', $_POST['newfile']);
$src = BASE_UPLOAD_PATH . DS . 'shop/member' . DS . $_POST['newfile'];
$avatarfile = BASE_UPLOAD_PATH . DS . 'shop/member' . DS . "store_avatar_{$_SESSION['store_id']}.jpg";
import('function.thumb');
$cropped = resize_thumb($avatarfile, $src, $w, $h, $x1, $y1, $scale);
@unlink($src);
Model()->table('store')->where(array('store_id' => $_SESSION['store_id']))->update(array('avatar' => 'store_avatar_' . $_SESSION['store_id'] . '.jpg'));
$_SESSION['store_avatar'] = 'store_avatar_' . $_SESSION['store_id'] . '.jpg';
redirect('index.php?act=storesetting&op=avatar');
}
}
示例6: grab_thumbs
function grab_thumbs($trade, $url, $trigger_strings = '')
{
global $C;
require_once 'http.php';
$images = array();
$grabbed = 0;
$trigger_strings = str_replace(',', '|', empty($trigger_strings) ? $C['thumb_trigger_strings'] : "{$trigger_strings}|{$C['thumb_trigger_strings']}");
$http = new HTTP();
$http->connect_timeout = 5;
$http->read_timeout = 10;
if (!$http->GET($url)) {
return null;
}
if (preg_match_all('~<img.*?>~msi', $http->body, $matches)) {
foreach ($matches[0] as $match) {
$attributes = array();
if (preg_match_all('~(?P<name>[a-z]+)\\s*=\\s*[\'"]?(?P<value>.*?)[\'"]?(?=\\s*[a-z]+\\s*=|\\s*/?>)~i', $match, $attrs, PREG_SET_ORDER)) {
foreach ($attrs as $attr) {
$attributes[strtolower(trim($attr['name']))] = $attr['value'];
}
$bad_height = isset($attributes['height']) && ($attributes['height'] < $C['thumb_height_min'] || $attributes['height'] > $C['thumb_height_max']);
$bad_width = isset($attributes['width']) && ($attributes['width'] < $C['thumb_width_min'] || $attributes['width'] > $C['thumb_width_max']);
$bad_src = !isset($attributes['src']) || !preg_match('~\\.(jpg|jpeg)~i', $attributes['src']) || !preg_match('~' . $trigger_strings . '~i', $attributes['src']);
if ($bad_width || $bad_height || $bad_src) {
continue;
}
$attributes['src'] = $http->_relative_to_absolute($url, $attributes['src']);
if ($http->GET($attributes['src'], $url, true)) {
$thumb_file = tempnam(DIR_TEMP, 'thumb');
file_write($thumb_file, $http->body);
$size = getimagesize($thumb_file);
if ($size != false && $size[0] >= $C['thumb_width_min'] && $size[0] <= $C['thumb_width_max'] && $size[1] >= $C['thumb_height_min'] && $size[1] <= $C['thumb_height_max']) {
$grabbed++;
rename($thumb_file, DIR_THUMBS . "/{$trade}-{$grabbed}.jpg");
resize_thumb(DIR_THUMBS . "/{$trade}-{$grabbed}.jpg", $size, $C['thumb_resize_width'], $C['thumb_resize_height']);
} else {
@unlink($thumb_file);
}
}
if ($grabbed >= $C['thumb_grab_amount']) {
break;
}
}
}
}
return $grabbed;
}