当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::crop方法代码示例

本文整理汇总了PHP中Image::crop方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::crop方法的具体用法?PHP Image::crop怎么用?PHP Image::crop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::crop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: imageResize

		static public function imageResize($fname,$width,$height) {
			$i = new Image( $fname );
			$owhr=$i->getWidth()/$i->getHeight();
			$twhr=$width/$height;
			if( $owhr==$twhr )	{
				$i->resize( $width,$height );
			}	elseif( $owhr>$twhr )	{
				$i->resizeToHeight( $height );
				$i->crop( ($i->getWidth()-$width)/2, 0, $width, $height);
			}	else	{
				$i->resizeToWidth( $width );
				$i->crop( 0, ($i->getHeight()-$height)/2, $width, $height);
			}
			$i->save();
		}
开发者ID:AuTiMoThY,项目名称:Dfocus-concord-php,代码行数:15,代码来源:JWStdio.inc.php

示例2: run

 public function run()
 {
     $rootPath = Yii::app()->getBasePath() . '/..';
     $fullpath = $rootPath . '/uploads/tmp/' . Yii::app()->request->getPost('im');
     if (file_exists($fullpath)) {
         $image = new Image($fullpath);
         $image->crop(Yii::app()->request->getPost('w'), Yii::app()->request->getPost('h'), Yii::app()->request->getPost('y'), Yii::app()->request->getPost('x'));
         $image->save();
         echo Yii::app()->request->getPost('imbox');
     }
 }
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:11,代码来源:AjaxCropAction.php

示例3: process

 public function process($args)
 {
     // get top/left crop offsets from query string (center is default)
     $top = Input::instance()->get('ctop', 'center');
     $left = Input::instance()->get('cleft', 'center');
     // ensure the values are valid
     $top = (is_numeric($top) or $top == 'top' or $top == 'center' or $top == 'bottom') ? $top : 'center';
     $left = (is_numeric($left) or $left == 'left' or $left == 'center' or $left == 'right') ? $left : 'center';
     // $rotate = Input::instance()->get('rotate');
     $flip = Input::instance()->get('flip');
     $flips = array('h' => 5, 'v' => 6);
     if (isset($this->row->preview_id) and $this->row->preview_id > 0) {
         $this->row = $this->row->preview;
     }
     if ($this->row->is_image) {
         $image = new Image(DATAPATH . 'uploads/' . $this->row->file_name);
         // if (!is_null($rotate) AND is_numeric($rotate)) { $image->rotate( (int) $rotate ); }
         if (!is_null($flip) and isset($flips[$flip])) {
             $image->flip($flips[$flip]);
         }
         $a = $image->width;
         $b = $image->height;
         if ($a != $args[0] or $b != $args[1]) {
             $s = $args[0] - $a;
             $t = $args[1] - $b;
             $r = max(($a + $s) / $a, ($b + $t) / $b);
             $x = $a * $r;
             $y = $b * $r;
             if (!is_numeric($args[0])) {
                 die('invalid width: ' . $args[0]);
             }
             if (!is_numeric($args[1])) {
                 die('invalid height: ' . $args[1]);
             }
             // $image->quality(75);
             $image->resize($x, $y, Image::NONE);
             $image->crop($args[0], $args[1], $top, $left);
         }
         $uniqid = '/tmp/temp_image-' . uniqid() . $this->row->file_ext;
         // Save to a temporary file
         $image->save($uniqid);
         $this->image->clear();
         $this->image->readImage($uniqid);
         unlink($uniqid);
         $border = Input::instance()->get('border', FALSE);
         if ($border) {
             $color = Input::instance()->get('bordercolor', null);
             $this->addborder($border, $color);
         }
     }
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:51,代码来源:Crop.php

示例4: doCrop

 public function doCrop($input)
 {
     if (!$this->api->authorized()) {
         return array('error' => 'not_logged_in');
     }
     $title = $input->title;
     $response = $this->api->getImageInfo($title);
     if ($response === false) {
         die('File was not found');
     }
     $sha1 = $response->imageinfo[0]->sha1;
     $ext = $this->getFileExt($response->imageinfo[0]->mime);
     $srcPath = $this->publicPath . '/files/' . $sha1 . $ext;
     $destPath = $this->publicPath . '/files/' . $sha1 . '_cropped' . $ext;
     $new_width = intval($input->w);
     $new_height = intval($input->h);
     $new_x = intval($input->x);
     $new_y = intval($input->y);
     $cropMethod = $input->cropmethod;
     if ($response->imageinfo[0]->mime == 'image/gif') {
         $cropMethod = 'gif';
     }
     $image = new Image($srcPath, $response->imageinfo[0]->mime);
     $s1 = array($image->width, $image->height);
     try {
         $res = $image->crop($cropMethod, $destPath, $new_x, $new_y, $new_width, $new_height);
     } catch (CropFailed $error) {
         return array('error' => 'Crop failed: ' . $error->getMessage());
     }
     $s2 = array($res['width'], $res['height']);
     // Make thumb
     $image = new Image($destPath, $response->imageinfo[0]->mime);
     $res['thumb'] = $image->thumb($this->publicPath . '/files/' . $sha1 . '_cropped_thumb' . $ext);
     $dim = array();
     if ($s1[0] != $s2[0]) {
         $cropPercentX = round(($s1[0] - $s2[0]) / $s1[0] * 100);
         $dim[] = ($cropPercentX ?: ' < 1') . ' % horizontally';
     }
     if ($s1[1] != $s2[1]) {
         $cropPercentY = round(($s1[1] - $s2[1]) / $s1[1] * 100);
         $dim[] = ($cropPercentY ?: ' < 1') . ' % vertically';
     }
     $using = 'using [[Commons:CropTool|CropTool]] with ' . $res['method'] . ' mode.';
     $res['dim'] = implode(' and ', $dim) . ' ' . $using;
     $res['page'] = $this->analyzePage($title);
     $this->logger->addInfo('[main] ' . substr($sha1, 0, 7) . ' Did crop using method: ' . $cm);
     return $res;
 }
开发者ID:omarjedhxxx44,项目名称:croptool,代码行数:48,代码来源:CropTool.php

示例5: cropResize

 public function cropResize($x1, $x2, $y1, $y2, $w, $h)
 {
     if (!$this->id) {
         return null;
     }
     $path = $this->getResizePath($w, $h);
     if (file_exists($this->getPath())) {
         $image = new Image($this->getPath());
         $image->crop($x2 - $x1, $y2 - $y1, $y1, $x1);
         $image->resize($w, $h);
         if (!file_exists(dirname($path))) {
             mkdir(dirname($path), 0777, true);
         }
         $image->save($path);
     }
     return $this->getResizeUrl($w, $h);
 }
开发者ID:schyzoo,项目名称:giiy,代码行数:17,代码来源:GiiyPicture.php

示例6: saveChanges

 function saveChanges()
 {
     $_POST->setType('filename', 'string');
     $_POST->setType('cropimgx', 'numeric');
     $_POST->setType('cropimgy', 'numeric');
     $_POST->setType('cropimgw', 'numeric');
     $_POST->setType('cropimgh', 'numeric');
     $_REQUEST->setType('mkcopy', 'string');
     if ($_REQUEST['filename']) {
         if ($_REQUEST['mkcopy']) {
             if ($_POST['filename'] != $this->basename && $_POST['filename']) {
                 if (!file_exists($this->dirname . '/' . $_POST['filename'])) {
                     $p = $this->dirname . '/' . $_POST['filename'];
                 } else {
                     Flash::queue(__('File exists. Please give another name or delete the conflicting file. Your changes were not saved.'), 'warning');
                     break;
                 }
             } else {
                 $nrofcopies = count(glob(substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy*'));
                 if ($nrofcopies == 0) {
                     $nrofcopies = '';
                 }
                 $p = substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy' . ($nrofcopies + 1) . substr($this->path, -(strlen($this->extension) + 1));
             }
             touch($p);
             $copy = File::open($p);
         } else {
             if ($_POST['filename'] != $this->basename) {
                 $this->rename($_POST['filename']);
             }
             $p = $this->path;
             $img = new Image($this->path);
             if ($_POST['cropimgw'] && $_POST['cropimgh']) {
                 $width = $img->width();
                 $s = $width / min($width, 400);
                 $img->crop(round($s * $_POST['cropimgx']), round($s * $_POST['cropimgy']), round($s * $_POST['cropimgw']), round($s * $_POST['cropimgh']));
             }
             if ($_REQUEST['imgrot']) {
                 $img->rotate($_REQUEST['imgrot']);
             }
             $img->save($p);
             Flash::queue(__('Your changes were saved'));
         }
     }
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:45,代码来源:ImageEditor.php

示例7: add

 public function add()
 {
     $user = User_Model::current();
     if ($post = $this->input->post('project')) {
         if (!$user->loaded) {
             return $this->template->content = 'You need to be logged in';
         }
         $project = ORM::factory('project');
         $validation = Projects_utils::projects_add_validation($post);
         if (!$project->validate($validation, true)) {
             return $this->template->content = Kohana::debug($validation->errors());
         }
         $post_user_data = $this->input->post('user');
         if (empty($post_user_data['role'])) {
             return $this->template->content = 'What was your role?!';
         }
         $project->add_user_roles(array($user->id => $post_user_data['role']));
         if (!empty($_FILES)) {
             $image_file = $_FILES['screenshot'];
             if (!$image_file['error']) {
                 $image = new Image($image_file['tmp_name']);
                 if ($image->width > 547) {
                     $image->resize(547, null);
                 }
                 $image->save(DOCROOT . '/media/project-images/' . $project->id . '.jpg');
             }
             $image_file = $_FILES['logo'];
             if (!$image_file['error']) {
                 $image = new Image($image_file['tmp_name']);
                 if ($image->width > 60) {
                     $image->resize(90, 90, Image::AUTO);
                 }
                 $image->crop(60, 60, 'center')->save(DOCROOT . '/media/project-images/' . $project->id . '-tiny.jpg');
             }
         }
         return url::redirect($project->local_url);
     } else {
         HTMLPage::add_style('forms');
         $this->template->content = new View('projects/add');
         $this->template->content->project_types = Projects_utils::get_project_types_dropdown_array();
         $this->template->content->user = $user;
     }
 }
开发者ID:hdragomir,项目名称:ProjectsLounge,代码行数:43,代码来源:projects.php

示例8: run

 public function run()
 {
     if (!Yii::app()->user->isGuest) {
         $im = Yii::app()->request->getPost('im');
         $inbase = ProductsImages::model()->findByAttributes(array('name' => $im), 'uploaded_by=' . Yii::app()->user->id);
         if (!$inbase) {
             throw new CHttpException(404, 'Ошибка.');
             return true;
         }
         $rootPath = Yii::app()->getBasePath() . '/..';
         $fullpath = $rootPath . '/uploads/obj/' . $im;
         if (file_exists($fullpath)) {
             $image = new Image($fullpath);
             $image->crop(Yii::app()->request->getPost('w'), Yii::app()->request->getPost('h'), Yii::app()->request->getPost('y'), Yii::app()->request->getPost('x'));
             $image->save();
             MCleaner::cleanTempImg($im);
             $inbase->getUrl('100x75');
             echo Yii::app()->request->getPost('imbox');
         }
     }
 }
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:21,代码来源:AjaxCropObjAction.php

示例9: run

 public function run()
 {
     if (!Yii::app()->user->isGuest) {
         $im = Yii::app()->request->getPost('im');
         $imbox = Yii::app()->request->getPost('imbox');
         $inbase = Shops::model()->findByAttributes(array($imbox => $im), 'real_admin=' . Yii::app()->user->id);
         $shop = new Shops();
         if (!$inbase) {
             throw new CHttpException(404, 'Ошибка.');
             return true;
         }
         $rootPath = Yii::app()->getBasePath() . '/..';
         $fullpath = $rootPath . '/uploads/shops/' . $inbase->id . '/photos/' . $im;
         if (file_exists($fullpath)) {
             $image = new Image($fullpath);
             $image->crop(Yii::app()->request->getPost('w'), Yii::app()->request->getPost('h'), Yii::app()->request->getPost('y'), Yii::app()->request->getPost('x'));
             $image->save();
             MCleaner::cleanTempImg($im, 'shop');
             $inbase->getUrl('220x114', 'resize', false, $im);
             echo Yii::app()->request->getPost('imbox');
         }
     }
 }
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:23,代码来源:AjaxCropSellerAction.php

示例10: Image

     }
 }
 if (empty($originalImage)) {
     $originalImage = $_POST['path'];
 }
 include_once CLASS_IMAGE;
 $image = new Image();
 if ($image->loadImage($originalImage)) {
     switch ($_POST['mode']) {
         case "resize":
             if (!$image->resize($_POST['width'], $_POST['height'], !empty($_POST['constraint']) ? true : false)) {
                 $error = IMG_SAVE_RESIZE_FAILED;
             }
             break;
         case "crop":
             if (!$image->crop($_POST['x'], $_POST['y'], $_POST['width'], $_POST['height'])) {
                 $error = IMG_SAVE_CROP_FAILED;
             }
             break;
         case "flip":
             if (!$image->flip($_POST['flip_angle'])) {
                 $error = IMG_SAVE_FLIP_FAILED;
             }
             break;
         case "rotate":
             if (!$image->rotate(intval($_POST['angle']))) {
                 $error = IMG_SAVE_ROTATE_FAILED;
             }
             break;
         default:
             $error = IMG_SAVE_UNKNOWN_MODE;
开发者ID:naneri,项目名称:Osclass,代码行数:31,代码来源:ajax_image_save.php

示例11: resizeImages

 function resizeImages($file, $directoryExtend, $watermark = '', $watermarkOver = 0, $watermarkPosition = '')
 {
     if (trim($file) == '') {
         return false;
     }
     if (is_array($this->photoSizes)) {
         require_once ENGINE_PATH . 'classes/image.class.php';
         $image = new Image();
         if ($watermark != '') {
             require_once ENGINE_PATH . 'classes/watermark.class.php';
             $wm = new watermark(DATA_SERVER_PATH . 'images/' . $watermark, $watermarkPosition);
         }
         recursive_mkdir(DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend);
         foreach ($this->photoSizes as $key => $size) {
             $image->enlarge = true;
             $resize = false;
             if (substr($size, 0, 1) == '_') {
                 $resize = true;
                 $size = substr($size, 1);
             }
             $sizes = explode('x', $size);
             if ($sizes[0] > 0) {
                 if ($sizes[1] == 0) {
                     $image->resize(DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $file, $sizes[0], 1000, DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $key . '_' . $file);
                 } else {
                     if ($resize) {
                         $image->enlarge = false;
                         $image->resize(DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $file, $sizes[0], $sizes[1], DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $key . '_' . $file);
                     } else {
                         $image->crop(DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $file, $sizes[0], $sizes[1], DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $key . '_' . $file);
                     }
                 }
                 if ($watermark != '' && $watermarkOver <= $sizes[1]) {
                     $wm->addWatermark(DATA_SERVER_PATH . "/uploads/" . $this->uploadFileDirectory . $directoryExtend . $key . '_' . $file);
                 }
             }
         }
     }
     return true;
 }
开发者ID:yunsite,项目名称:demila,代码行数:40,代码来源:base.class.php

示例12: dirname

define('CARD_DIR', dirname(__FILE__) . '/card');
define('SOURCE_DIR', dirname(__FILE__) . '/source');
define('SPOIL_CARD', '_');
define('WIDTH', 140);
define('HEIGHT', 105);
$cutRange = [[248, 270], [248, 540], [248, 810], [248, 1080], [1323, 270], [1323, 540], [1323, 810], [1323, 1080]];
$images = ['img51.jpg', 'img54.jpg', 'img57.jpg', 'img60.jpg', 'img63.jpg'];
$cardnum = [0, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14, 16, 19, 17, 18, 20, 22, 23, 24, 25, 26, 28, 29, 27, 31, 33, 35, 36, 21, 32, 30, 34, 0, 0];
$count = 0;
foreach ($images as $imgname) {
    foreach ($cutRange as $r) {
        list($x, $y) = $r;
        $thumb = new Image(SOURCE_DIR . '/' . $imgname);
        $thumb->width(WIDTH);
        $thumb->height(HEIGHT);
        $thumb->crop($x, $y);
        $thumb->dir(CARD_DIR);
        $name = $cardnum[$count++];
        $thumb->name($name == 0 ? SPOIL_CARD : $name);
        $thumb->save();
    }
}
// 消費財
$thumb = new Image(SOURCE_DIR . '/' . 'img63.jpg');
$thumb->width(WIDTH);
$thumb->height(HEIGHT);
$thumb->crop(1323, 1110);
$thumb->dir(CARD_DIR);
$thumb->name('99');
$thumb->save();
unlink(CARD_DIR . '/' . SPOIL_CARD . '.jpg');
开发者ID:sopra,项目名称:NationalEconomySolo,代码行数:31,代码来源:cutter.php

示例13: manipulate

 private function manipulate($file, $options)
 {
     // validate options
     $this->validateOptions($options);
     $targetFolder = $options['folder'];
     $fileName = $options['fileName'];
     // path for new image
     $path = $this->getAbsolutePath($targetFolder, $fileName);
     if ($this->mkdir && !file_exists(dirname($path))) {
         mkdir(dirname($path), 0777, true);
     }
     // image copy if should not be resized
     if (isset($options['resize']) && !$options['resize']) {
         copy($file->getTempName(), $path);
         return;
     }
     // width and hight for new image
     $targetWidth = $options['width'];
     $targetHeight = $options['height'];
     // width and hight of uploaded image
     list($uploadedWidth, $uploadedHeight) = getimagesize($file->getTempName());
     // image copy if should not be resized
     if (isset($options['smartResize']) && !$options['smartResize']) {
         // if needed image more than uploaded image then nothing change
         if ($targetWidth > $uploadedWidth && $targetHeight > $uploadedHeight) {
             copy($file->getTempName(), $path);
         } else {
             // get image for manipulate from temp folder
             $image = new Image($file->getTempName());
             // manipulate
             $image->resize($targetWidth, $targetHeight, Image::AUTO)->sharpen(1)->quality(95)->save($path);
         }
         return;
     }
     // relation of side uploaded and new image
     $uploadedRatio = $uploadedWidth / $uploadedHeight;
     $targetRatio = $targetWidth / $targetHeight;
     // compare the relation and calculate coordinates for clipping
     if ($uploadedRatio > $targetRatio) {
         $cropHeight = $uploadedHeight;
         $cropWidth = $uploadedHeight * $targetRatio;
         $cropLeft = ($uploadedWidth - $uploadedHeight * $targetRatio) * 0.5;
         $cropTop = 0;
     } else {
         $cropHeight = $uploadedWidth / $targetRatio;
         $cropWidth = $uploadedWidth;
         $cropLeft = 0;
         $cropTop = ($uploadedHeight - $uploadedWidth / $targetRatio) * 0.2;
     }
     // get image for manipulate from temp folder
     $image = new Image($file->getTempName());
     // manipulate
     $image->crop($cropWidth, $cropHeight, $cropTop, $cropLeft)->resize($targetWidth, $targetHeight, Image::NONE)->sharpen(1)->quality(95)->save($path);
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:54,代码来源:SImageUploadBehavior.php

示例14: insertImage

 protected function insertImage($id, $values)
 {
     $request = Request::getInstance();
     // get settings
     $calSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS);
     $globalSettings = $this->plugin->getSettings();
     $settings = array_merge($globalSettings, $calSettings->getSettings($values['tree_id'], $values['tag']));
     $destWidth = $settings['image_width'];
     $destHeight = $settings['image_height'];
     $maxWidth = $settings['image_max_width'];
     // user global if tree values are not set
     if (!$destWidth) {
         $destWidth = $globalSettings['image_width'];
     }
     if (!$destHeight) {
         $destHeight = $globalSettings['image_height'];
     }
     if (!$maxWidth) {
         $maxWidth = $globalSettings['image_max_width'];
     }
     $imgX = $values['img_x'];
     $imgY = $values['img_y'];
     $path = $this->plugin->getContentPath(true);
     $filename = strtolower($this->getClassName()) . "_" . $id['id'];
     // check if image is uploaded
     $img = $values['image'];
     $upload = is_array($img) && $img['tmp_name'];
     if ($upload) {
         // image is new uploaded image
         $image = new Image($img);
         $imgWidth = $image->getWidth();
         $imgHeight = $image->getHeight();
         $ext = Utils::getExtension($img['name']);
         $originalFile = "{$filename}.{$ext}";
         $croppedFile = $filename . "_thumb.{$ext}";
         // delete current image if filename new filename is different
         $detail = $this->getDetail($id);
         if ($detail['image'] && $detail['image'] != $originalFile) {
             $this->deleteImage($detail);
         }
         // resize original image. (increase size if necessary)
         if ($maxWidth > 0 && $imgWidth > $maxWidth) {
             $image->resize($maxWidth);
         } elseif ($imgWidth < $destWidth || $imgHeight < $destHeight) {
             if ($image->getWidth() < $destWidth) {
                 $image->resize($destWidth, 0, true);
             }
             if ($image->getHeight() < $destHeight) {
                 $image->resize(0, $destHeight, true);
             }
         }
         $image->save($path . $originalFile);
     } else {
         // no image provided. check if one exists
         $detail = $this->getDetail($id);
         if (!$detail['image']) {
             return;
         }
         // get original image
         $image = new Image($detail['image'], $this->plugin->getContentPath(true));
         $ext = Utils::getExtension($detail['image']);
         $originalFile = "{$filename}.{$ext}";
         $croppedFile = $filename . "_thumb.{$ext}";
     }
     // only crop if both width and height settings are set and image is big enough, else do a resize
     if ($destWidth && $destHeight) {
         // crop image
         if ($upload) {
             // calculate area of crop field
             // first assume width is smalles side
             $newWidth = $image->getWidth();
             $newHeight = $newWidth / $destWidth * $destHeight;
             if ($newHeight > $image->getHeight()) {
                 // width was larger than height, so use height as smallest side
                 $newHeight = $image->getHeight();
                 $newWidth = $newHeight / $destHeight * $destWidth;
             }
             // center crop area
             $imgX = intval($image->getWidth() / 2 - $newWidth / 2);
             $imgY = intval($image->getHeight() / 2 - $newHeight / 2);
         } else {
             $newWidth = $values['img_width'];
             $newHeight = $values['img_height'];
         }
         // crop image
         $image->crop($imgX, $imgY, $newWidth, $newHeight, $destWidth, $destHeight);
         // save cropped and overlayed image
         $image->save($path . $croppedFile);
     } else {
         // resize image
         $image->resize($destWidth, $destHeight);
         $newWidth = $image->getWidth();
         $newHeight = $image->getHeight();
         $image->save($path . $croppedFile);
     }
     $db = $this->getDb();
     $query = sprintf("update calendar set cal_image= '%s', cal_thumbnail = '%s', cal_img_x = %d, cal_img_y = %d, cal_img_width = %d, cal_img_height = %d where cal_id = %d", addslashes($originalFile), addslashes($croppedFile), $imgX, $imgY, $newWidth, $newHeight, $id['id']);
     $res = $db->query($query);
     if ($db->isError($res)) {
         throw new Exception($res->getDebugInfo());
//.........这里部分代码省略.........
开发者ID:rverbrugge,项目名称:dif,代码行数:101,代码来源:CalendarOverview.php

示例15: edit

 public function edit($id)
 {
     global $mysql, $langArray;
     if (!isset($_POST['name']) || trim($_POST['name']) == '') {
         $error['name'] = $langArray['error_fill_this_field'];
     }
     if (!isset($_POST['description']) || trim($_POST['description']) == '') {
         $error['description'] = $langArray['error_fill_this_field'];
     }
     if (isset($error)) {
         return $error;
     }
     $photo = $this->upload('photo', '', false);
     if (substr($photo, 0, 6) == 'error_') {
         $error['photo'] = $langArray[$photo];
     }
     if (isset($error)) {
         return $error;
     }
     $setQuery = '';
     if ($photo != '' || isset($_POST['deletePhoto'])) {
         $this->deletePhoto($id);
     }
     if ($photo != '') {
         $setQuery .= " `photo` = '" . sql_quote($photo) . "', ";
     }
     if (!isset($_POST['visible'])) {
         $_POST['visible'] = 'false';
     }
     if ($photo) {
         #剪裁缩略图并创建预览图
         require_once ENGINE_PATH . '/classes/image.class.php';
         $imageClass = new Image();
         if (!file_exists(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . '/260x140/')) {
             mkdir(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . '/260x140/', 0777, true);
         }
         if (!file_exists(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . '/192x64/')) {
             mkdir(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . '/192x64/', 0777, true);
         }
         $imageClass->crop(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . $photo, 260, 140, DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . '/260x140/' . $photo);
         $imageClass->crop(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . $photo, 260, 140, DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . '/192x64/' . $photo);
     }
     $mysql->query("\n\t\t\tUPDATE `qnews`\n\t\t\tSET `name` = '" . sql_quote($_POST['name']) . "',\n\t\t\t    `description` = '" . sql_quote($_POST['description']) . "',\n\t\t\t\t`url` = '" . sql_quote($_POST['url']) . "',\n\t\t\t\t\t{$setQuery}\n\t\t\t\t\t`visible` = '" . sql_quote($_POST['visible']) . "'\n\t\t\tWHERE `id` = '" . intval($id) . "'\n\t\t", __FUNCTION__);
     return true;
 }
开发者ID:yunsite,项目名称:demila,代码行数:45,代码来源:qnews.class.php


注:本文中的Image::crop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。