本文整理汇总了PHP中SimpleImage::resize方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleImage::resize方法的具体用法?PHP SimpleImage::resize怎么用?PHP SimpleImage::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: imageDualResize
function imageDualResize($filename, $cleanFilename, $wtarget, $htarget)
{
if (!file_exists($cleanFilename)) {
$dims = getimagesize($filename);
$width = $dims[0];
$height = $dims[1];
while ($width > $wtarget || $height > $htarget) {
if ($width > $wtarget) {
$percentage = $wtarget / $width;
}
if ($height > $htarget) {
$percentage = $htarget / $height;
}
/*if($width > $height)
{
$percentage = ($target / $width);
}
else
{
$percentage = ($target / $height);
}*/
//gets the new value and applies the percentage, then rounds the value
$width = round($width * $percentage);
$height = round($height * $percentage);
}
$image = new SimpleImage();
$image->load($filename);
$image->resize($width, $height);
$image->save($cleanFilename);
$image = null;
}
//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
return "src=\"{$baseurl}/{$cleanFilename}\"";
}
示例2: InsertMemory
function InsertMemory($memorydate, $imgname, $userid, $location, $title)
{
global $objSmarty, $config;
if ($this->con->Conectar() == true) {
$memdate = $this->changeDateformut($memorydate);
$memoryphoto = "";
$root_url = $_SERVER[DOCUMENT_ROOT] . '/memoryphoto/';
$location_url = $_SERVER[DOCUMENT_ROOT] . '/includes/app/pics_temp/';
if ($imgname != "") {
$resizeObj = new SimpleImage($location . $imgname);
if ($width >= "1000") {
$resizeObj->resize(800, 650);
$resizeObj->save($root_url . $imgname);
}
if ($width >= "800" && $width < "1000") {
$resizeObj->resize(600, 460);
$resizeObj->save($root_url . $imgname);
}
if ($width >= "600" && $width < "800") {
$resizeObj->resize(400, 260);
$resizeObj->save($root_url . $imgname);
}
$name = $imgname;
//@move_uploaded_file($_FILES['memoryphoto']['tmp_name'], "memoryphoto/".$name);exit;
$memoryphoto = " `MemoryPhoto` = '" . addslashes($imgname) . "', ";
$resizeObj = new SimpleImage($location . $name);
$resizeObj->resize(160, 160);
$resizeObj->save($root_url . "thumbnail/" . $name);
$memoryphotothumb = " `MemoryPhotoThumbnail` = '" . addslashes($name) . "', ";
$resizeObj->resize(850, 450);
$resizeObj->save($root_url . "850x450/" . $name);
$resizeObj->resize(300, 290);
$resizeObj->save($root_url . "300x290/" . $name);
$filename = $root_url . $name;
rename($location . $name, $filename);
} else {
//echo "ELSE";exit;
$memoryphoto = " `MemoryPhoto` = 'photo_not_available.jpg', ";
//$memoryphoto=" `MemoryPhoto` = ".'photo_not_available.jpg'.',';
$memoryphotothumb = " `MemoryPhotoThumbnail` = 'photo_not_available.jpg', ";
}
$InsQuery = "INSERT INTO `tbl_mymemories` \n\t\t\tset `MemberID`= '" . $userid . "' ,\n\t\t\t`MemoryTitle`= '" . addslashes($title) . "',\n\t\t\t`MemoryDate`= '" . $memdate . "' ,\n\t\t\t{$memoryphoto} \n\t\t\t{$memoryphotothumb} \n\t\t\t`Status`= '1' ,\n\t\t\t`CreatedDateTime`= NOW()";
$insertid = mysql_query($InsQuery);
$last_insert_id = mysql_insert_id();
/* Insert For Showing The Recent Activities Starts Here */
$activity_comment = "created new memory from app.";
$Recent_Activity = "INSERT INTO `tbl_recent_activity` \n\t\t\t(`activity_id`, `A_MemberID`,`A_FriendID`, `Added_Page`, `Activity_Comment`, `Table_Fetch`, `PhotoId`, `Privacy`, `Status`, `createdtime`) \n\t\t\tVALUES ('','" . $userid . "','','Memory','" . $activity_comment . "','memory','" . $last_insert_id . "','1','1',now())";
$Recent_Insert = mysql_query($Recent_Activity);
return "MEmory has been created successfully.";
} else {
return "Database Error";
}
}
示例3: insertImageSub
function insertImageSub($file, $sub_id, $menu_id)
{
$error = false;
$arr = explode('.', $file["name"]);
$imageFileType = end($arr);
if ($file["size"] > 5000000) {
$error = true;
}
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$error = true;
}
if (!$error) {
$target_dir = "../images/menu_" . $menu_id . "/sub_" . $sub_id . "/";
$target_file = $target_dir . $file["name"];
//
if (!file_exists($target_dir)) {
mkdir($target_dir, 0777, true);
}
if (file_exists($target_file)) {
unlink($target_file);
}
if (move_uploaded_file($file["tmp_name"], $target_file)) {
include 'classSimpleImage.php';
$image = new SimpleImage();
$image->load($target_file);
$image->resize(218, 138);
$image->save($target_file);
$arr = explode("../", $target_file);
return end($arr);
}
} else {
return false;
}
}
示例4: action_index
public function action_index()
{
$tags = array();
$imager = new SimpleImage();
if ($this->request->param('path')) {
// Берем новость
$post = ORM::factory('blog')->where('url', '=', $this->request->param('path'))->find();
} else {
$post = ORM::factory('blog');
}
if ($_POST) {
$post_name = Arr::get($_POST, 'post_name');
$post_url = Arr::get($_POST, 'post_url');
$short_text = Arr::get($_POST, 'short_text');
$full_text = Arr::get($_POST, 'full_text');
$tag = Arr::get($_POST, 'tag');
// Загрузка изображения
$image = $_FILES["imgupload"]["name"];
if (!empty($image)) {
$imager = new SimpleImage();
//$this->news->deleteImage($post->id);
//$image = $this->image->upload_image($image['tmp_name'], $image['name'], $this->config->news_images_dir."big/");
move_uploaded_file($_FILES["imgupload"]["tmp_name"], "files/blog/" . $_FILES["imgupload"]["name"]);
$imager->load("files/blog/" . $image);
$imager->resize(200, 200);
$imager->save("files/blog/miniatures/" . $image);
}
$post->set('name', $post_name)->set('url', $post_url)->set('date', DB::expr('now()'))->set('short_text', $short_text)->set('full_text', $full_text)->set('image', $image)->set('tag_id', ORM::factory('tags')->where('name', '=', $tag)->find())->save();
}
$tags = ORM::factory('tags')->find_all();
$content = View::factory('/admin/post')->bind('tags', $tags)->bind('post', $post);
$this->template->content = $content;
}
示例5: ImageResize
function ImageResize($file)
{
$image = new SimpleImage();
$image->load('traffic-images/temp/' . $file);
$image->resize(300, 200);
$image->save('traffic-images/' . $file);
unlink("traffic-images/temp/" . $file);
}
示例6: saveImageInFile
public function saveImageInFile($file)
{
$t = $file['tmp_name'];
$n = $file['name'];
$path = App::get("uploads_dir_original") . DIRECTORY_SEPARATOR . $n;
move_uploaded_file($t, $path);
$image = new SimpleImage();
$image->load($path);
$image->resize(250, 250);
$image->save(App::get("uploads_dir_small") . DIRECTORY_SEPARATOR . $n);
return $n;
}
示例7: scale
function scale($size = 100)
{
if (!$this->image && !$this->checked) {
$this->get();
}
if (!$this->image) {
return false;
}
// New code to get rectangular images
require_once mnminclude . "simpleimage.php";
$thumb = new SimpleImage();
$thumb->image = $this->image;
if ($thumb->resize($size, $size, true)) {
//$this->image = $thumb->image;
//$this->x=imagesx($this->image);
//$this->y=imagesy($this->image);
return $thumb;
}
return false;
}
示例8: Thumbnail
static function Thumbnail($image_file, $thumb_file, $width = 48, $height = 48)
{
$ctype = FSS_Helper::datei_mime("png");
// thumb file exists
if (file_exists($thumb_file) && filesize($thumb_file) > 0) {
header("Content-Type: " . $ctype);
header('Cache-control: max-age=' . 60 * 60 * 24 * 365);
header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365));
@readfile($thumb_file);
exit;
}
require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'third' . DS . 'simpleimage.php';
$im = new SimpleImage();
$im->load($image_file);
if (!$im->image) {
// return a blank thumbnail of some sort!
$im->load(JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'assets' . DS . 'images' . DS . 'blank_16.png');
}
$im->resize($width, $height);
$im->output();
$im_data = ob_get_clean();
if (strlen($im_data) > 0) {
// if so use JFile to write the thumbnail image
JFile::write($thumb_file, $im_data);
} else {
// it failed for some reason, try doing a direct write of the thumbnail
$im->save($thumb_file);
}
header('Cache-control: max-age=' . 60 * 60 * 24 * 365);
header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365));
header("Content-Type: " . $ctype);
if (file_exists($thumb_file && filesize($thumb_file) > 0)) {
@readfile($thumb_file);
} else {
$im->output();
}
exit;
}
示例9: imageResize
function imageResize($filename, $cleanFilename, $target)
{
if (!file_exists($cleanFilename)) {
$dims = getimagesize($filename);
$width = $dims[0];
$height = $dims[1];
//takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image
if ($width > $height) {
$percentage = $target / $width;
} else {
$percentage = $target / $height;
}
//gets the new value and applies the percentage, then rounds the value
$width = round($width * $percentage);
$height = round($height * $percentage);
$image = new SimpleImage();
$image->load($filename);
$image->resize($width, $height);
$image->save($cleanFilename);
$image = null;
}
//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
return "src=\"{$baseurl}/{$cleanFilename}\"";
}
示例10: Admin
require_once "../lib/classes/Content.php";
require_once "../lib/simpleimage.php";
$adminObj = new Admin();
$ContentObj = new Content();
$ImageObj = new SimpleImage();
$adminObj->validateAdmin();
if (isset($_POST['submitForm'])) {
if (empty($_POST['ModelId'])) {
if ($_FILES['model_master_image']['error'] == 0) {
$ModelName = mysql_real_escape_string($_POST['model_name']);
$ModelMasterImage = time('his') . $_FILES['model_master_image']['name'];
$path = "../uploaded_images/{$ModelMasterImage}";
$thumbPath = "../uploaded_images/thumb/{$ModelMasterImage}";
move_uploaded_file($_FILES['model_master_image']['tmp_name'], $path);
$ImageObj->load($path);
$ImageObj->resize(300, 300);
$ImageObj->save($thumbPath);
$obj->query("insert into tbl_model set model_name='{$ModelName}',model_master_image\t='{$ModelMasterImage}',status=1,add_date=CURDATE()");
$modelId = mysql_insert_id();
$obj->query("insert into tbl_model_cover_photo set model_id = '{$modelId}' , cover_image_name = '{$ModelMasterImage}' , status=1 , add_date=CURDATE()");
$commonObj->pushMessage("Model has been uploaded successfully.");
$commonObj->wtRedirect("models.php");
} else {
$commonObj->pushError("Opps!Error in file uploading try again.");
}
} else {
if ($_FILES['model_master_image']['error'] == 0) {
$ModelName = mysql_real_escape_string($_POST['model_name']);
$ModelMasterImage = time('his') . $_FILES['model_master_image']['name'];
$model_desc = mysql_real_escape_string($_POST['model_desc']);
$path = "../uploaded_images/{$ModelMasterImage}";
示例11: handleUpload
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
function handleUpload($uploadDirectory, $replaceOldFile = FALSE)
{
$folder = getcwd() . '/uploads/';
$thumbFolder = getcwd() . '/uploads/thumbs/';
if (!is_writable($uploadDirectory)) {
return array('error' => "Server error. Upload directory isn't writable.");
}
if (!$this->file) {
return array('error' => 'No files were uploaded.');
}
$size = $this->file->getSize();
if ($size == 0) {
return array('error' => 'File is empty');
}
if ($size > $this->sizeLimit) {
return array('error' => 'File is too large');
}
$pathinfo = pathinfo($this->file->getName());
$filename = $pathinfo['filename'];
//$filename = md5(uniqid());
$ext = $pathinfo['extension'];
if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
$these = implode(', ', $this->allowedExtensions);
return array('error' => 'File has an invalid extension, it should be one of ' . $these . '.');
}
if (!$replaceOldFile) {
/// don't overwrite previous files that were uploaded
while (file_exists($uploadDirectory . $filename . '.' . $ext)) {
$filename .= rand(10, 99);
}
}
if ($this->file->save($uploadDirectory . $filename . '.' . $ext)) {
$image = new SimpleImage();
$image->load($folder . $filename . '.' . $ext);
$width = $image->getWidth();
$height = $image->getHeight();
$image->resize(150, 150);
$image->save('uploads/thumbs/' . $filename . '-thumb.' . $ext);
return array('success' => true, 'size' => $size, 'width' => $width, 'height' => $height, 'extension' => $ext, 'file_name' => $filename);
} else {
return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
}
}
示例12: json_encode
$params = UploadFileCURL::getParamsPostUrl($_POST['data']);
$remote_file = $_FILES['file'];
if (!empty($params['path_img_thumb']) && !empty($params['path_img_larger'])) {
$path_img_larger = $params['system'] . '/' . $params['path_img_larger'];
UploadFileCURL::CreatePathPermission($path_img_larger);
$path_img_thumb = $params['system'] . '/' . $params['path_img_thumb'];
UploadFileCURL::CreatePathPermission($path_img_thumb);
} elseif (!empty($params['path'])) {
$path = $params['system'] . '/' . $params['path'];
UploadFileCURL::CreatePathPermission($path);
}
foreach ($remote_file['name'] as $key => $value) {
$file = array('name' => $value, 'type' => $remote_file['type'][$key], 'tmp_name' => $remote_file['tmp_name'][$key], 'error' => $remote_file['error'][$key], 'size' => $remote_file['size'][$key]);
if ($remote_file['type'][$key] == 'image/jpeg' || $remote_file['type'][$key] == 'image/png') {
UploadFileCURL::upload($path_img_larger, $file);
$img_larger = $path_img_larger . UploadFileCURL::getNameFile();
$img_thumb = $path_img_thumb . UploadFileCURL::getNameFile();
$params['file'][] = array('img_larger' => $img_larger, 'img_thumb' => $img_thumb);
if (!empty($params['thumb_width']) && !empty($params['thumb_heigth'])) {
$simpleImage = new SimpleImage();
$simpleImage->load($img_larger);
$simpleImage->resize($params['thumb_width'], $params['thumb_heigth']);
$simpleImage->save($img_thumb);
}
} else {
UploadFileCURL::upload($path, $file);
$file_path = $path . UploadFileCURL::getNameFile();
$params['file'][] = array('file_path' => $file_path);
}
}
echo json_encode($params);
示例13: basename
$photo =time().$_FILES['photo'.$v]['name']; $_POST['p_color'];
mysql_query("INSERT INTO tbl_img(user_id,product_id,product_img)
VALUES('$user_id','$product_id','$p_color')");
} */
} else {
echo 'error in adding';
}
if ($_FILES['sign']['name'] != '') {
//include('SimpleImage.php');
$target_path = 'uploads/';
$target_path = $target_path . basename(time() . $_FILES['sign']['name']);
if (move_uploaded_file($_FILES['sign']['tmp_name'], $target_path)) {
$sign = time() . $_FILES['sign']['name'];
$image1 = new SimpleImage();
$image1->load("uploads/" . $sign);
$image1->resize(200, 100);
$image1->save("uploads/thumb/" . $sign);
}
/*for($v=1;$v<=5; $v++){
$photo =time().$_FILES['photo'.$v]['name']; $_POST['p_color'];
mysql_query("INSERT INTO tbl_img(user_id,product_id,product_img)
VALUES('$user_id','$product_id','$p_color')");
} */
} else {
echo 'error in adding';
}
mysql_query("INSERT INTO membership( name, address,Telephone,Residenace,representative,doe,Category,mem_type,Business,Products,Proposed,Seconded,Place,date,sign1_id,sign2_id,sign_id) VALUES('{$name}','{$address}','{$Telephone}','{$Residenace}','{$representative}','{$doe}','{$Category}','{$mem_type}','{$Business}','{$Products}','{$Proposed}','{$Seconded}','{$Place}','{$date}','{$sign1}','{$sign2}','{$sign}')");
echo "<script language='javascript'> window.location='apply_mem.php'; </script>";
exit;
}
?>
示例14: cropPhoto
public function cropPhoto()
{
$my = JFactory::getUser();
$ajax = DiscussHelper::getHelper('Ajax');
if (!$my->id) {
$ajax->reject(JText::_('You are not allowed here'));
return $ajax->send();
}
$config = DiscussHelper::getConfig();
$profile = DiscussHelper::getTable('Profile');
$profile->load($my->id);
$path = rtrim($config->get('main_avatarpath'), DIRECTORY_SEPARATOR);
$path = JPATH_ROOT . '/' . $path;
$photoPath = $path . '/' . $profile->avatar;
$originalPath = $path . '/' . 'original_' . $profile->avatar;
// @rule: Delete existing image first.
if (JFile::exists($photoPath)) {
JFile::delete($photoPath);
}
$x1 = JRequest::getInt('x1');
$y1 = JRequest::getInt('y1');
$width = JRequest::getInt('width');
$height = JRequest::getInt('height');
if (is_null($x1) && is_null($y1) && is_null($width) && is_null($height)) {
$ajax->reject(JText::_('Unable to crop because cropping parameters are incomplete!'));
return $ajax->send();
}
require_once DISCUSS_CLASSES . '/simpleimage.php';
$image = new SimpleImage();
$image->load($originalPath);
$image->crop($width, $height, $x1, $y1);
$image->resize(160, 160);
$image->save($photoPath);
$path = trim($config->get('main_avatarpath'), '/') . '/' . $profile->avatar;
$uri = rtrim(JURI::root(), '/');
$uri .= '/' . $path;
$ajax->resolve($uri, 'Avatar cropped successfully!');
return $ajax->send();
}
示例15: error
$s1 = 1;
if (!$res) {
error('File Type not allowed!! You can only upload JPEG,PNG,BMP and GIF images.');
$s1 = 0;
}
$name = str_replace(' ', '_', $name);
$name = get_rand_id(15) . '_' . $name;
$target = $target . $name;
$mimg = kbase() . '/kart/' . $target;
$timg = kbase() . '/kart/' . "itemimage/thumb_" . $name;
if (move_uploaded_file($_FILES['mimg']['tmp_name'], $target)) {
$s2 = 1;
$path = "itemimage/thumb_" . $name;
$image = new SimpleImage();
$image->load($target);
$image->resize(150, 100);
$image->save($path);
delete($_POST['mimg']);
delete($_POST['timg']);
} else {
error('Error Uploading Main Image !!');
$s2 = 0;
}
} else {
$mimg = $_POST['mimg'];
$timg = $_POST['timg'];
$s1 = 1;
$s2 = 1;
}
// ***************************** Image 2 ********************
if (basename($_FILES['img1']['name'])) {