Ejemplo n.º 1
0
 /**
  * Initialize image properties
  *
  * Resets values in case this class is used in a loop
  *
  * @access  public
  * @return  void
  */
 function clear()
 {
     $this->user_width = 0;
     $this->user_height = 0;
     $this->user_x_axis = '';
     $this->user_y_axis = '';
     return parent::clear();
 }
Ejemplo n.º 2
0
 /**
  * Initialize image properties
  *
  * Resets values in case this class is used in a loop
  *
  * @access	public
  * @return	void
  */
 public function clear()
 {
     $result = parent::clear();
     $this->user_width = 0;
     $this->user_height = 0;
     $this->user_x_axis = '';
     $this->user_y_axis = '';
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Generate a URI string from an associative array. Added noemptys parameter
  *
  * @access	public
  * @param	array	an associative array of key/values
  * @param	boolean	indicates whether to remove empty array values from uri
  * @return	array
  */
 public function initialize($props = array())
 {
     foreach ($this->_save_props as $sp) {
         $p = '_' . $sp;
         if (isset($props[$sp])) {
             $this->{$p} = $props[$sp];
         }
     }
     parent::initialize($props);
 }
Ejemplo n.º 4
0
 function MY_Image_lib($props = array())
 {
     $convert_path = $this->_get_convert_path();
     if ($convert_path === FALSE) {
         $props['image_library'] = 'gd2';
     } else {
         $props['image_library'] = 'imagemagick';
         $props['library_path'] = $convert_path;
     }
     parent::CI_Image_lib();
 }
Ejemplo n.º 5
0
 /**
  * Execute cropping with current params
  * @param int $x - pixels from top
  * @param int $y - pixels from left
  * @param int $width - width from initial point in pixels
  * @param int $height - height from initial point in pixels
  * @throws \Exception
  * @return string - new file name
  */
 public function execute($x, $y, $width = null, $height = null)
 {
     if (!isset($this->params['source_image'])) {
         throw new \Exception('Cropping cannot be completed because source image is not set.');
     }
     $this->prepareParams($x, $y, $width, $height);
     $this->imageLib->initialize($this->params);
     //print_d($this->params);
     $this->imageLib->crop();
     return $this->params['new_image'];
 }
Ejemplo n.º 6
0
 /**
  * 
  * @param string|integer $id (Primary Key)
  * @param string $name
  * @param string $folder (posts/images)
  * @return boolean
  */
 public static function upload($field, $id, $name, $folder, $config = array())
 {
     $CI =& get_instance();
     $ciConfig = $CI->config->item('utils');
     $config['upload_path'] = $path = $ciConfig['upload_dir'] . $folder . '/';
     $config['allowed_types'] = 'gif|jpg|png';
     $config['file_name'] = $fileName = self::getFileName($id, self::IMAGE_ORIGINAL, $name);
     $CI->load->library('upload');
     $CI->load->library('image_lib');
     $upload = new CI_Upload($config);
     if (!$upload->do_upload($field)) {
         return $upload->display_errors('', '');
     } else {
         $imageConfig = array('source_image' => $path . $fileName);
         foreach (array(self::IMAGE_LARGE, self::IMAGE_MEDIUM, self::IMAGE_SMALL) as $size) {
             $imageConfig['new_image'] = $path . self::getFileName($id, $size, $name);
             //                list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower($size)]);
             list($imageConfig['width']) = explode('x', $ciConfig['image'][strtolower($size)]);
             $image = new CI_Image_lib();
             $image->initialize($imageConfig);
             $image->resize();
             $image->clear();
         }
         $imageConfig['new_image'] = $path . self::getFileName($id, self::IMAGE_THUMB, $name);
         list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower(self::IMAGE_THUMB)]);
         $imageConfig['maintain_ratio'] = FALSE;
         $image = new CI_Image_lib();
         $image->initialize($imageConfig);
         $image->resize();
         $image->clear();
         return TRUE;
     }
 }
Ejemplo n.º 7
0
 public function processImage($template_id)
 {
     if (empty($template_id)) {
         return;
     }
     $this->CI->load->helper("upload");
     $path = UPLOAD_PATH . '../template/';
     $config['upload_dir'] = $path;
     $config['upload_dir'] = $config['upload_dir'];
     if (!is_dir($config['upload_dir'])) {
         //create the folder if it's not already exists
         mkdir($config['upload_dir'], 0755, TRUE);
     }
     $config['script_url'] = base_url() . $path;
     $config['upload_url'] = base_url() . $path;
     $upload_handler = new UploadHandler($config);
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             //$id_template= $template_id;
             $upload_dir = dirname($_SERVER['SCRIPT_FILENAME']) . $path;
             $url = base_url();
             $files = array();
             $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : "FRONT";
             //echo $type;
             if ($images = $this->CI->template_m->get_images($template_id, $type)) {
                 foreach ($images as $img) {
                     $returnpath = $path . $template_id . '_' . $img->id_image . $this->img_extension;
                     if (file_exists($returnpath)) {
                         $file = new stdClass();
                         $file->name = $template_id . '_' . $img->id_image . $this->img_extension;
                         $file->id_image = $img->id_image;
                         $file->url = $path . $template_id . '_' . $img->id_image . $this->img_extension;
                         $file->delete_url = site_url() . '/admin/template/img_upload' . '?id_image=' . rawurlencode($img->id_image) . '&&id_template=' . rawurlencode($template_id);
                         $file->delete_url .= '&&method=DELETE';
                         $file->deleteType = 'DELETE';
                         $file->url_default = site_url() . '/admin/template/set_default/' . $template_id . '/' . $img->id_image . '/' . $img->type;
                         $files[] = $file;
                     }
                 }
             }
             $obj = new stdClass();
             $obj->files = $files;
             ob_clean();
             print_r(json_encode($obj));
             ob_flush();
             break;
         case 'POST':
             if (isset($_REQUEST['method']) && $_REQUEST['method'] === 'DELETE') {
                 $upload_handler->delete();
             } else {
                 $id_template = $template_id;
                 $type = $this->CI->input->post('type') ? $this->CI->input->post('type') : "FRONT";
                 //parent::create($this->fields);
                 if (isset($_FILES['files'])) {
                     if ($timage = $this->CI->template_m->createimage($template_id, $type)) {
                         $new_file_path = $path . $id_template . "_" . $timage->id_image . $this->img_extension;
                         if (isset($_FILES['files']['tmp_name'][0])) {
                             $file_path = $_FILES['files']['tmp_name'][0];
                             if (file_exists($file_path)) {
                                 if ($file_path !== $new_file_path) {
                                     //	 @copy($file_path, $new_file_path);
                                     $config['image_library'] = 'gd2';
                                     $config['source_image'] = $file_path;
                                     $config['new_image'] = $new_file_path;
                                     $config['maintain_ratio'] = TRUE;
                                     $config['height'] = MAX_TEMPLATE_HEIGHT;
                                     $this->CI->load->library('image_lib');
                                     $resizer = new CI_Image_lib();
                                     $resizer->initialize($config);
                                     $resizer->resize();
                                 }
                             }
                         }
                     }
                     $files_return = array();
                     //     foreach ($images as $img) {
                     $file = new stdClass();
                     $file->name = $id_template . '_' . $timage->id_image . $this->img_extension;
                     $file->id_image = $timage->id_image;
                     $file->url = $path . $id_template . '_' . $timage->id_image . $this->img_extension;
                     $file->delete_url = $this->getFullUrl() . '/admin/template/img_upload' . '?id_image=' . rawurlencode($timage->id_image) . '&&id_template=' . rawurlencode($id_template);
                     $file->delete_url .= '&&method=DELETE';
                     $file->deleteType = 'DELETE';
                     $file->url_default = site_url() . '/admin/template/set_default/' . $id_template . '/' . $timage->id_image . '/' . $type;
                     $files_return[] = $file;
                     //  };
                     $object = new stdClass();
                     $object->files = $files_return;
                     ob_clean();
                     print_r(json_encode($object));
                     ob_flush();
                 }
             }
             break;
         case 'DELETE':
             if (!isset($_REQUEST['id_image'])) {
                 return;
             }
             if (!isset($_REQUEST['id_template'])) {
                 return;
             }
             $tid = $_REQUEST['id_template'];
             $image_id = $_REQUEST['id_image'];
             $this->CI->template_m->deleteimage($_REQUEST['id_image'], $_REQUEST['id_template']);
             $deltepath = $path . $tid . '_' . $image_id . $this->img_extension;
             //	echo $deltepath;die;
             if (file_exists($deltepath)) {
                 @unlink($deltepath);
             }
             ob_clean();
             ob_flush();
             //echo json_encode($this->tools->set_notification('N', 'notice', 'Delete successfull'));
             return;
             break;
         default:
             header('HTTP/1.1 405 Method Not Allowed');
     }
 }
Ejemplo n.º 8
0
 function Image_Filters($props = array())
 {
     parent::__construct($props);
 }
Ejemplo n.º 9
0
 function MY_Image_lib($props = array())
 {
     parent::__construct($props);
 }
Ejemplo n.º 10
0
 /**
  * Constructor method
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::CI_Image_lib();
 }
Ejemplo n.º 11
0
 /**
  * Construct
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
 }
Ejemplo n.º 12
0
$config['create_thumb']     = TRUE;
//$config['maintain_ratio']   = FALSE; //TRUE;//default true
$config['master_dim']       = 'height'; //'width'; //TRUE;
$config['width']            = 275;
$config['height']           = 250;

$imglib = new CI_Image_lib($config);
if ( !$imglib->resize() ) {
    echo $imglib->display_errors();
}*/
$config['source_image'] = 'cute.jpg';
$config['new_image'] = './thumb/wt_cute.jpg';
$config['wm_text'] = 'Copyright 2010 - Nissi Audio';
$config['wm_type'] = 'text';
$config['wm_font_path'] = './fonts/osaka-re.ttf';
$config['wm_font_size'] = '16';
$config['wm_font_color'] = '#3f0101';
$config['wm_shadow_color'] = '#a7a6aa';
$config['wm_shadow_distance'] = 1;
//$config['wm_vrt_alignment'] = 'bottom';
$config['wm_vrt_alignment'] = 'middle';
$config['wm_hor_alignment'] = 'center';
//wm type = image
$config['wm_opacity'] = 10;
//$config['wm_padding'] = '20';
$imglib = new CI_Image_lib();
$imglib->initialize($config);
if (!$imglib->watermark()) {
    echo $imglib->display_errors();
}
print_log($_SESSION['log']);
Ejemplo n.º 13
0
 private function importProcessImage($id, $imgPath)
 {
     $img = $this->template_m->createimage($id);
     //echo $imgPath;die;
     $returnpath = $this->tplateImageFolder . $id . '_' . $img->id_image . '.png';
     if (file_exists($imgPath)) {
         $config['image_library'] = 'gd2';
         $config['source_image'] = $imgPath;
         $config['new_image'] = $returnpath;
         $config['maintain_ratio'] = TRUE;
         $config['height'] = 600;
         $this->load->library('image_lib');
         $resizer = new CI_Image_lib();
         $resizer->initialize($config);
         $resizer->resize();
         return true;
     } else {
         return;
     }
 }
Ejemplo n.º 14
0
/**
 * resize image
 * @author phplaw@gmail.com
 * @param array $opt array of config
 * @return mixed thumb_name or false when resize fail 
 */
function generate_thumb($opt = array())
{
    $config['image_library'] = 'gd2';
    $config['source_image'] = $opt['file_to_resize'];
    $config['thumb_marker'] = '';
    $config['new_image'] = $opt['thumb_dir'];
    $config['create_thumb'] = TRUE;
    $config['master_dim'] = 'width';
    $config['width'] = $opt['width'];
    $config['height'] = $opt['height'];
    $CI_Image_lib = new CI_Image_lib($config);
    if ($CI_Image_lib->resize()) {
        return $CI_Image_lib->dest_image;
    }
    return false;
}
 function __construct($props = array())
 {
     parent::__construct($props);
 }
 function MY_Image_lib($props = array())
 {
     parent::CI_Image_lib($props);
 }
Ejemplo n.º 17
0
 function __construct()
 {
     parent::__construct();
 }