本文整理汇总了PHP中resizeThumbnailImage函数的典型用法代码示例。如果您正苦于以下问题:PHP resizeThumbnailImage函数的具体用法?PHP resizeThumbnailImage怎么用?PHP resizeThumbnailImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resizeThumbnailImage函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPicDb
public function addPicDb($tid, $title, $picUrl, $yid, $lid)
{
//检测是否已经有此图片
$isExists = $this->dbPic->frow("picurl='{$picUrl}'");
if (!empty($isExists)) {
return true;
}
$yPicFile = $this->copyYuantu($picUrl);
if ($yPicFile == false) {
return false;
}
$picName = substr($yPicFile, strrpos($yPicFile, '/') + 1);
$hPicPath = $this->hpicPath . date('YmdH') . '/';
$mPicPath = $this->mpicPath . date('YmdH') . '/';
$lPicPath = $this->lpicPath . date('YmdH') . '/';
$tPicPath = $this->tpicPath . date('YmdH') . '/';
if (!is_dir($hPicPath)) {
mkdir($hPicPath);
chmod($hPicPath, 777);
}
if (!is_dir($mPicPath)) {
mkdir($mPicPath);
chmod($mPicPath, 777);
}
if (!is_dir($lPicPath)) {
mkdir($lPicPath);
chmod($lPicPath, 777);
}
if (!is_dir($tPicPath)) {
mkdir($tPicPath);
chmod($tPicPath, 777);
}
$hPicFile = resizeThumbnailImage($hPicPath . $picName, $yPicFile, $this->sHpic);
$mPicFile = resizeThumbnailImage($mPicPath . $picName, $yPicFile, $this->sMpic);
$lPicFile = resizeThumbnailImage($lPicPath . $picName, $yPicFile, $this->sLpic);
$tPicFile = resizeThumbnailImage($tPicPath . $picName, $yPicFile, 1, $this->sTpic);
$insert = array('lid' => $lid, 'yid' => $yid, 'tid' => $tid, 'picurl' => $picUrl, 'pname' => $title, 'ypicurl' => substr($yPicFile, strpos($yPicFile, '/upload')), 'hpicurl' => substr($hPicFile, strpos($hPicFile, '/upload')), 'mpicurl' => substr($mPicFile, strpos($mPicFile, '/upload')), 'lpicurl' => substr($lPicFile, strpos($lPicFile, '/upload')), 'tpicurl' => substr($tPicFile, strpos($tPicFile, '/upload')), 'status' => 1, 'created' => time());
return $this->dbPic->insert($insert);
}
示例2: header
//Refresh the page to show the new uploaded image
header("location:" . $_SERVER["PHP_SELF"]);
exit;
}
}
if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists) > 0) {
//Get the new coordinates to crop the image.
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Scale the image to the thumb_width set above
$scale = $thumb_width / $w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale);
//Reload the page again to view the thumbnail
//header("location:".$_SERVER["PHP_SELF"]);
$login_id = $_SESSION['userid'];
$dbimagefilename = str_replace("uploads/profile/", "", $thumb_image_location);
require_once "db/db.php";
$data_layer = new db_layer();
$update_query = mysql_query("update registration SET profile_pic='{$dbimagefilename}' where id={$login_id}") or die("{$sql_error}" . mysql_error());
mysql_close();
Header("Location:imagesavesuccess.php");
exit;
}
if ($_GET['a'] == "delete" && strlen($_GET['t']) > 0) {
//get the file locations
$large_image_location = $upload_path . $large_image_prefix . $_GET['t'];
$thumb_image_location = $upload_path . $thumb_image_prefix . $_GET['t'];
示例3: blogsmu_features_page
//.........这里部分代码省略.........
}
} else {
$error = __("Select an image for upload", TEMPLATE_DOMAIN);
}
//Everything is ok, so we can upload the image.
if (strlen($error) == 0) {
if (isset($_FILES['image']['name'])) {
move_uploaded_file($userfile_tmp, $normal_image_location);
chmod($normal_image_location, 0777);
//Delete the thumbnail file so the user can create a new one
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
}
//Refresh the page to show the new uploaded image
print '<meta http-equiv="Pragma" content="no-cache">';
echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>";
echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">';
print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">";
exit;
//double refresh to clear cache..its a bit catchy but it get the job done
}
}
if (isset($_POST['upload_thumbnail1']) && strlen($large_photo_exists) > 0) {
//Get the new coordinates to crop the image.
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Scale the image to the thumb_width set above
$scale = $thumb_width / $w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale);
//Refresh the page to show the new uploaded image
print '<meta http-equiv="Pragma" content="no-cache">';
echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>";
echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">';
print "<meta http-equiv=\"refresh\" content=\"5;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">";
exit;
//double refresh to clear cache..its a bit catchy but it get the job done
}
?>
<?php
//Only display the javacript if an image has been uploaded
if (strlen($large_photo_exists) > 0) {
$current_large_image_width = getWidth($large_image_location);
$current_large_image_height = getHeight($large_image_location);
?>
<script type="text/javascript">
function preview(img, selection) {
var scaleX = <?php
echo $thumb_width;
?>
/ selection.width;
var scaleY = <?php
echo $thumb_height;
?>
/ selection.height;
$('#thumbnail + div > img').css({
width: Math.round(scaleX * <?php
echo $current_large_image_width;
?>
) + 'px',
示例4: form_file
//.........这里部分代码省略.........
//이미지 사이즈가 작으면 선택영역을 최대로 한다.
$temp_width = getWidth($uploaded);
$temp_height = getHeight($uploaded);
if ($thumb_height == $thumb_width) {
if ($temp_width < $thumb_width) {
$resize_width = $temp_width;
}
if ($temp_height < $thumb_height) {
$resize_height = $temp_height;
}
if ($resize_width > $resize_height) {
$resize_width = $resize_height;
} else {
$resize_height = $resize_width;
}
} else {
//둘 다 현재 이미지 보다 큰 경우
if ($resize_height > $temp_height && $resize_width > $temp_width) {
$resize_width = $temp_width;
$resize_height = $temp_height;
if ($resize_width > $resize_height) {
$resize_width = $resize_height * ($thumb_width / $thumb_height);
} else {
$resize_height = $resize_width * ($thumb_height / $thumb_width);
}
} else {
if ($resize_height <= $temp_height && $resize_width >= $temp_width) {
$resize_width = $temp_width;
$resize_height = $temp_width * ($thumb_height / $thumb_width);
} else {
if ($resize_width <= $temp_width && $resize_height >= $temp_height) {
$resize_height = $temp_height;
$resize_width = $temp_height * ($thumb_width / $thumb_height);
} else {
echo "*********" . $resize_width . ' ' . $temp_width . '-----' . $resize_height . ' ' . $temp_height;
}
}
}
}
if (file_exists($large_image_location)) {
$large_photo_exists = $large_image_location;
$current_large_image_width = getWidth($large_image_location);
$current_large_image_height = getHeight($large_image_location);
} else {
$large_photo_exists = "";
$thumb_photo_exists = "";
}
$this->assigns['current_large_image_width'] = $current_large_image_width;
$this->assigns['current_large_image_height'] = $current_large_image_height;
$this->assigns['thumb_width'] = $thumb_width;
$this->assigns['thumb_height'] = $thumb_height;
$this->assigns['resize_width'] = $resize_width;
$this->assigns['resize_height'] = $resize_height;
$this->assigns['large_photo_exists'] = $large_photo_exists;
$this->assigns['sub_large_image_location'] = '/' . $sub_large_image_location;
}
//업로드를 변경 했다면
if (array_key_exists('thumb_width', $_REQUEST)) {
//Get the new coordinates to crop the image.
$start = strpos($sub_dir, "/", 6) + 1;
$end = strpos($sub_dir, "/", strpos($sub_dir, "/", 6) + 1);
$length = $end - $start;
$temp_size_str = substr($sub_dir, $start, $length);
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
$thumb_width = $_POST["thumb_width"];
// if($sub_dir == 'media/member/'){
// $tmp_thumbnail = $sub_dir.$_SESSION['s']['id'].".jpg";
// }else{
//
// $tmp_thumbnail = $sub_dir;
// }
$tmp_thumbnail = 'resize_temp' . strtotime(date('Y-m-d H:i:s')) . '.' . jpg;
//취약점 보안
if (array_key_exists('large_image', $_POST)) {
$low_str = strtolower($_POST["large_image"]);
for ($i = 0; $i < sizeof($this->settings->weak_part); $i++) {
$pattern = '/^\\/' . $this->settings->weak_part[$i] . '\\/resize_temp[0-9]+.(jpg|gif|jpeg|png)$/';
if (preg_match($pattern, $low_str, $match)) {
break;
}
}
}
$thumb_image = $this->settings->root_path . 'media/temp/' . $tmp_thumbnail;
$large_image = $this->settings->root_path . $_POST["large_image"];
$scale = $thumb_width / $w;
resizeThumbnailImage($thumb_image, $large_image, $w, $h, $x1, $y1, $scale);
//리사이즈용 임시 이미지 삭제
if (file_exists($large_image)) {
unlink($large_image);
}
$this->assigns['thumbnail'] = '/media/temp/' . $tmp_thumbnail;
}
$this->assigns['r_width'] = $_REQUEST['r_width'];
$this->assigns['r_height'] = $_REQUEST['r_height'];
}
示例5: imagecreatefromgif
$source = imagecreatefromgif($image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source = imagecreatefromjpeg($image);
break;
case "image/png":
case "image/x-png":
$source = imagecreatefrompng($image);
break;
}
imagecopyresampled($newImage, $source, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $imagewidth, $imageheight);
switch ($imageType) {
case "image/gif":
imagegif($newImage, $thumb);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($newImage, $thumb, 100);
break;
case "image/png":
case "image/x-png":
imagepng($newImage, $thumb);
break;
}
return $thumb;
}
resizeThumbnailImage($thumb, $image, $scale, array('width' => 64, 'height' => 64));
示例6: wpmudev_custom_homepage_admin
//.........这里部分代码省略.........
$error = __("Select an image for upload", TEMPLATE_DOMAIN);
}
//Everything is ok, so we can upload the image.
if (strlen($error) == 0) {
if (isset($_FILES['image']['name'])) {
move_uploaded_file($userfile_tmp, $normal_image_location);
chmod($normal_image_location, 0777);
//Delete the thumbnail file so the user can create a new one
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
}
//Refresh the page to show the new uploaded image
print '<meta http-equiv="Pragma" content="no-cache">';
echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>";
echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">';
print "<meta http-equiv=\"refresh\" content=\"1;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php\">";
print "<script>";
print " self.location='{$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1';";
print "</script>";
exit;
}
}
if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists) > 0) {
//Get the new coordinates to crop the image.
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Scale the image to the thumb_width set above
$scale = $thumb_width / $w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale);
//Reload the page again to view the thumbnail
//Refresh the page to show the new uploaded image
print '<meta http-equiv="Pragma" content="no-cache">';
echo "<h4 id=\"loading-bar\">Please wait..Your Image Currently Processing</h4>";
echo '<img src="' . get_template_directory_uri() . '/_inc/admin/loading_bar.gif' . '">';
print "<meta http-equiv=\"refresh\" content=\"3;url={$ttpl_url}/wp-admin/themes.php?page=custom-homepage.php&#tab1\">";
exit;
}
?>
<?php
//Only display the javacript if an image has been uploaded
if (strlen($large_photo_exists) > 0) {
$current_large_image_width = getWidth($large_image_location);
$current_large_image_height = getHeight($large_image_location);
?>
<script type="text/javascript">
function preview(img, selection) {
var scaleX = <?php
echo $thumb_width;
?>
/ selection.width;
var scaleY = <?php
echo $thumb_height;
?>
/ selection.height;
$('#thumbnail + div > img').css({
width: Math.round(scaleX * <?php
echo $current_large_image_width;
?>
) + 'px',