$image->image_to_resize = CC_PATH . '/uploads/' . $_POST['img'];
 $image->ratio = false;
 $image->new_image_name = $_POST['id'];
 $image->save_folder = '../../../people/';
 $process = $image->resize();
 if ($process['result'] && $image->save_folder) {
     foreach ($_POST['del'] as $value) {
         unlink("../../../uploads/{$value}");
     }
     $new = 'people/' . $process['new_name'];
     //update db
     $q = $dbh->prepare("UPDATE cm_users SET picture_url = :url WHERE id = :id");
     $data = array('url' => $new, 'id' => $_POST['id']);
     $q->execute($data);
     //now make the thumbnail
     $thumb = new Resize_Image();
     $thumb->new_width = 32;
     $thumb->source_x = 0;
     $thumb->source_y = 0;
     $thumb->dest_x = 0;
     $thumb->dest_y = 0;
     $thumb->image_to_resize = CC_PATH . '/' . $new;
     $thumb->ratio = true;
     $thumb->new_image_name = 'tn_' . $_POST['id'];
     $thumb->save_folder = '../../../people/';
     $process = $thumb->resize();
     if ($process['result'] && $thumb->save_folder) {
         $return = array('success' => true, 'img' => $new);
         echo json_encode($return);
     }
 }
Example #2
0
 if ($is_error == false) {
     $_target = $_root_app . $_target . basename($_FILES['uploadedfile']['name']);
     $file_tmp = JHotelUtil::makePathFile($_target);
     /* if( is_file($file_tmp) )
     			 {
     			$p	=	'';
     			$n	= 	basename( $file_tmp);
     			$i	=	'This file exist !';
     			$e	=	1;
     			}
     			else
     			{ */
     //dmp($_FILES['uploadedfile']['name']);
     if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $file_tmp)) {
         if ($resizeImage) {
             $image = new Resize_Image();
             $image->ratio = true;
             $ratio = PICTURE_WIDTH / PICTURE_HEIGHT;
             $size = getimagesize($file_tmp);
             $imageRatio = $size[0] / $size[1];
             //set new height or new width depending on image ratio
             if ($ratio < $imageRatio) {
                 $image->new_width = PICTURE_WIDTH;
             } else {
                 $image->new_height = PICTURE_HEIGHT;
             }
             $image->image_to_resize = $file_tmp;
             // Full Path to the file
             $image->new_image_name = basename($file_tmp);
             $image->save_folder = dirname($file_tmp) . DIRECTORY_SEPARATOR;
             $process = $image->resize();
Example #3
0
<?php

set_time_limit(10000);
error_reporting(E_ALL ^ E_NOTICE);
include 'resize.image.class-2.php';
$resize_image = new Resize_Image();
// Folder where the (original) images are located with trailing slash at the end
$images_dir = '';
// Image to resize
$image = $_GET['image'];
/* Some validation */
if (!@file_exists($image)) {
    exit('The requested image does not exist.');
}
// Get the new with & height
$new_width = (int) $_GET['new_width'];
$new_height = (int) $_GET['new_height'];
$resize_image->new_width = $new_width;
$resize_image->new_height = $new_height;
$resize_image->image_to_resize = $images_dir . $image;
// Full Path to the file
$resize_image->ratio = true;
// Keep aspect ratio
$process = $resize_image->resize();
// Output image