Exemplo n.º 1
0
 public function beforeSave($options = array())
 {
     $imageRes = new ImageResize();
     $this->data['User']['status'] = 1;
     if (isset($this->data['User']['photo'])) {
         $data = $this->data['User']['photo'];
         $path = dirname(__FILE__) . '/../../app/webroot/user_image/';
         $file = $imageRes->resize($data, 300, 220, $path);
         $this->data['User']['photo'] = $file;
     }
 }
Exemplo n.º 2
0
<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="UTF-8">
	<title>Ejemplo</title>

</head>
<body>
	<h1 id="titulo">Ejemplo</h1>
	
	<div>
		
		<?php 
require "ImageResize.php";
$src = "archivo.jpg";
$dest = "archivo150x150.jpg";
$resize = new ImageResize($src);
$resize->resize(150, 150);
if (!@$resize->save($dest)) {
    echo "Archivo no fue generado. Error: " . error_get_last();
} else {
    echo "Archivo {$dest} generado.";
}
?>

	</div>
</body>
</html>

Exemplo n.º 3
0
 if (empty($_POST['name']) || empty($_POST['class']) || empty($_POST['roll'])) {
     echo '<script>std_empty();</script>';
     echo "<meta http-equiv='refresh' content='1;url='>";
     exit;
 }
 $image_name = isset($_FILES['edit-students-image']['name']) ? $_FILES['edit-students-image']['name'] : NULL;
 $tmp_name = isset($_FILES['edit-students-image']['tmp_name']) ? $_FILES['edit-students-image']['tmp_name'] : NULL;
 $rand_img = !empty($image_name) ? rand(1000, 9999) . '.jpg' : '';
 if (!empty($image_name)) {
     $students_img_location = $plug_path . 'images/scl_students/' . $rand_img;
     if (!empty($image_name)) {
         $mime = getimagesize($tmp_name);
         if (in_array('image', explode('/', $mime['mime']))) {
             move_uploaded_file($tmp_name, $students_img_location);
             $image = new ImageResize($students_img_location);
             $image->resize(140, 140);
             $image->save();
             copy($students_img_location, 'img/admin/student_' . $rand_img);
         }
     }
 }
 $fields = array('id' => $_POST['id'], 'name' => $_POST['name'], 'class' => $_POST['class'], 'roll' => $_POST['roll'], 'gender' => $_POST['gender'], 'address' => $_POST['address'], 'date_of_birth' => $_POST['date_of_birth'], 'mobile' => $_POST['mobile'], 'email' => $_POST['email']);
 if (!empty($image_name)) {
     $fields['image'] = $rand_img;
 }
 $where = array('id' => $_POST['id']);
 if (db_update('scl_students', $fields, $where)) {
     $fields = array('full_name' => $_POST['name'], 'email' => $_POST['email']);
     $where = array('username' => 'student_' . $_POST['id']);
     if (isset($image_name)) {
         $student_acc_img = 'student_' . $rand_img;
Exemplo n.º 4
0
<?php

require_once './ImageResize.php';
$imgsdir = 'imgs/';
$scale = 300;
$im = new ImageResize($imgsdir, $scale);
$filelist = $im->get_file($im->dirname);
$path = $im->filetype($filelist);
$target = $im->image_info($path);
$im->resize($target);
$im->reduction($im->resized);
Exemplo n.º 5
0
 /**
  * Resizes an image and returns the image contents
  * @param string $image_location
  * @param integer $dest_width
  * @param integer $dest_height
  * @param integer $dest_padding
  * @return string
  */
 static function resizeImageFromString($image_source_contents, $dest_width = 128, $dest_height = 128, $dest_padding = 5)
 {
     $image_resize = new ImageResize();
     $image_resize->setDestinationImageHeight($dest_height);
     $image_resize->setDestinationImageWidth($dest_width);
     $image_resize->setDestinationImagePadding($dest_padding);
     return $image_resize->resize($image_source_contents);
 }
 public function resize()
 {
     $this->loadFile();
     $imageResize = new ImageResize($this->file);
     $imageResize->resize(900);
 }
Exemplo n.º 7
0
<?php

include 'ImageResize.php';
?>

<?php 
//EJEMPLO DE USO DE LA CLASE ImageResize:
$nombreDeImagen = "imagenX";
$src = PATH_IMG . $nombreDeImagen . ".jpg";
$dest1 = PATH_IMG_R50x50 . $nombreDeImagen . ".jpg";
$dest2 = PATH_IMG_R150x150 . $nombreDeImagen . ".jpg";
$imagen = new ImageResize($src);
$imagen->resize(50, 50);
@$imagen->save($dest1);
$imagen->resize(150, 150);
if (!@$imagen->save($dest2)) {
    echo "Archivo no fue generado. Error: " . error_get_last();
} else {
    echo "Archivo {$dest2} generado.";
}
Exemplo n.º 8
0
 $uptmp = strlen(ini_get('upload_tmp_dir')) > 0 ? ini_get('upload_tmp_dir') : (strlen($_ENV['TEMP']) > 0 ? $_ENV['TEMP'] : (strlen($_ENV['TMP']) > 0 ? $_ENV['TMP'] : (strtolower(substr(PHP_OS, 0, 3)) == 'win' ? 'C:/WINDOWS/TEMP' : '/tmp')));
 $oldfile = $uptmp . '/' . $_SESSION['jieqiUserId'] . '_tmp' . $jieqiConfigs['system']['avatardt'];
 if (is_file($oldfile)) {
     if ($old_avatar > 0 && isset($jieqi_image_type[$old_avatar])) {
         $old_imagefile = $basedir . '/' . $jieqiUsers->getVar('uid', 'n') . $jieqi_image_type[$old_avatar];
         jieqi_delfile($old_imagefile);
     }
     $posary = explode(',', $_REQUEST['cut_pos']);
     foreach ($posary as $k => $v) {
         $posary[$k] = intval($v);
     }
     include_once JIEQI_ROOT_PATH . '/lib/image/imageresize.php';
     $imgresize = new ImageResize();
     $imgresize->load($oldfile);
     if ($posary[2] > 0 && $posary[3] > 0) {
         $imgresize->resize($posary[2], $posary[3]);
     }
     $imgresize->cut($jieqiConfigs['system']['avatardw'], $jieqiConfigs['system']['avatardh'], intval($posary[0]), intval($posary[1]));
     $tmp_save = $uptmp . '/' . $_SESSION['jieqiUserId'] . $jieqiConfigs['system']['avatardt'];
     $imgresize->save($tmp_save);
     jieqi_copyfile($tmp_save, $newfile, 0777, true);
     $imgresize->resize($jieqiConfigs['system']['avatarsw'], $jieqiConfigs['system']['avatarsh']);
     $tmp_save = $uptmp . '/' . $_SESSION['jieqiUserId'] . 's' . $jieqiConfigs['system']['avatardt'];
     $imgresize->save($tmp_save);
     jieqi_copyfile($tmp_save, $smallfile, 0777, true);
     $imgresize->resize($jieqiConfigs['system']['avatariw'], $jieqiConfigs['system']['avatarih']);
     $tmp_save = $uptmp . '/' . $_SESSION['jieqiUserId'] . 'i' . $jieqiConfigs['system']['avatardt'];
     $imgresize->save($tmp_save, true);
     jieqi_copyfile($tmp_save, $iconfile, 0777, true);
     jieqi_delfile($oldfile);
     $image_type = 0;
Exemplo n.º 9
0
} elseif ($act == 'save_teachers_photo_cutting') {
    $teachers = get_teachers_one(intval($_REQUEST['pid']), intval($_SESSION['uid']));
    if (empty($teachers)) {
        showmsg("请先填写讲师基本信息!", 0);
    }
    require_once QISHI_ROOT_PATH . 'include/imageresize.class.php';
    $imgresize = new ImageResize();
    $photo_dir = QISHI_ROOT_PATH . substr($_CFG['teacher_photo_dir'], strlen($_CFG['site_dir']));
    $photo_thumb_dir = QISHI_ROOT_PATH . substr($_CFG['teacher_photo_dir_thumb'], strlen($_CFG['site_dir']));
    $imgresize->load($photo_dir . $teachers['photo_img']);
    $posary = explode(',', $_POST['cut_pos']);
    foreach ($posary as $k => $v) {
        $posary[$k] = intval($v);
    }
    if ($posary[2] > 0 && $posary[3] > 0) {
        $imgresize->resize($posary[2], $posary[3]);
    }
    $imgresize->cut(120, 150, intval($posary[0]), intval($posary[1]));
    $imgresize->save($photo_thumb_dir . $teachers['photo_img']);
    header('Location: ?act=photo_cutting&show=ok&pid=' . $_REQUEST['pid']);
} elseif ($act == 'edit_photo_display') {
    header('Location: ?act=teachers_show&id=' . intval($_REQUEST['pid']));
} elseif ($act == 'teachers_show') {
    $teachers = get_teachers_one(intval($_GET['id']), $_SESSION['uid']);
    if (empty($teachers)) {
        showmsg("参数错误!", 1);
    }
    $smarty->assign('title', '修改讲师资料 - 培训会员中心 - ' . $_CFG['site_name']);
    $smarty->assign('teachers', $teachers);
    $smarty->display('member_train/train_teachersshow.htm');
} elseif ($act == 'del_teachers') {