本文整理汇总了PHP中upload::resizeImage方法的典型用法代码示例。如果您正苦于以下问题:PHP upload::resizeImage方法的具体用法?PHP upload::resizeImage怎么用?PHP upload::resizeImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类upload
的用法示例。
在下文中一共展示了upload::resizeImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
continue;
}
}
}
if (!$imgUp->finish_upload(isset($admin_upload) ? 1 : null)) {
if ($imgUp->error_code == 125) {
user_feedback('error', '<b>' . $imgUp->info['full_name'] . '</b> ' . _T("site_upload_err") . ' .', 'filemove');
}
continue;
}
//Resize image if needed
if ($settings['SET_RESIZE_IMG_ON']) {
if (isset($_POST['new_width'][$i]) && !empty($_POST['new_width'][$i]) || isset($_POST['new_height'][$i]) && !empty($_POST['new_height'][$i])) {
$imgUp->stretchSmallImages(true);
if (!empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])) {
$imgUp->resizeImage($_POST['new_width'][$i], $_POST['new_height'][$i], 'exact');
} elseif (!empty($_POST['new_width'][$i]) && empty($_POST['new_height'][$i])) {
$imgUp->resizeImage($_POST['new_width'][$i], $imgUp->info['width'], 'landscape');
} elseif (empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])) {
$imgUp->resizeImage($imgUp->info['height'], $_POST['new_height'][$i], 'portrait');
}
$imgUp->saveImage($imgUp->info['address'], 100, null, true);
$imgUp->info['size'] = filesize($imgUp->info['address']);
// get new image file size
$imgUp->stretchSmallImages(false);
// set it back to false
}
}
// check for theme Settings
$THUMB_OPTION = theme_setting('thumb_option', $THUMB_OPTION);
$THUMB_MAX_WIDTH = theme_setting('thumb_max_width', $THUMB_MAX_WIDTH);
示例2:
//Image Locations
$large_image_location = $upload_path . $large_image_name . $file_ext;
$thumb_image_location = $upload_path . $thumb_image_name . $file_ext;
//Everything is ok, so we can upload the image.
if (isset($_FILES['image']['name'])){
move_uploaded_file($userfile_tmp, $large_image_location);
chmod($large_image_location, 0777);
$width = $upload->getWidth($large_image_location);
$height = $upload->getHeight($large_image_location);
//Scale the image if it is greater than the width set above
if ($width > $max_width) {
$scale = $max_width / $width;
$uploaded = $upload->resizeImage($large_image_location,$width,$height,$scale);
} else {
$scale = 1;
$uploaded = $upload->resizeImage($large_image_location,$width,$height,$scale);
}
//Delete the thumbnail file so the user can create a new one
/*if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}*/
}
if (file_exists($large_image_location)) {
$thumb_photo_exists = $upload_path . $large_image_name . $file_ext;
$large_photo_exists = $upload_path . $large_image_name . $file_ext;
}