El problema está cuando quiero escalar propocionalemnte dicha imagen, para hacer la captura pero resulta que la función, por algun razón, no me está funcionando. Lo que quiero es tomar como parámetro que la imagen en uno de los casos no sea menos ancho q 64 y menos alto que 64, por lo tando, si el ancho es mas que el alto, entonces escalaría el alto hasta dar con 64, total el ancho nunca sería menos ya que tiene mas px q el alto. Y visceverza.
Miren la funcion donde están los: "*****************************"
Aqui les dejo el código para aquellos que se atrevan a leerlo y darme vuestra opinión en donde está la falla.
Gracias!
Código :
<?php { { // Cargamos modelo principal $this->load->model( 'upload_m' ); //Helpers $this->load->helper( 'form' ); // Propiedades del controlador $this->error = ''; $this->success = ''; $this->sizes_mid = array( 206, 206 ); $this->sizes_small = array( 64, 64 ); } public function index() { if ( $this->input->post( 'submit' ) ) { $this->load->library( 'form_validation' ); // Primero chequeamos la descripcion $this->form_validation->set_rules( 'descripcion', '"Descripcion de la Imagen"', 'trim|required|max_length[255]' ); if ( $this->form_validation->run() === true ) { // Procedemos al upload de la imagen $this->load->library( 'upload' ); $config = array(); $config[ 'upload_path' ] = './images/usuarios/'; $config[ 'allowed_types' ] = 'gif|jpg|png'; $config[ 'max_size' ] = '2048'; $config[ 'encrypt_name' ] = true; $this->upload->initialize( $config ); $this->upload->do_upload( 'imagen' ); if ( $this->upload->display_errors() ) { $this->error = $this->upload->display_errors(); } else { ***************************// Generamos los thumbs $data = $this->upload->data(); if ( $data[ 'width' ] > $data[ 'height' ] ) { $config[ 'master_dim' ] = 'height'; } else { $config[ 'master_dim' ] = 'width'; } $config[ 'image_library' ] = 'gd2'; $config[ 'source_image' ] = $data[ 'full_path' ]; $config[ 'create_thumb' ] = true; $config[ 'maintain_ratio' ] = true; $config[ 'thumb_marker' ] = '_thumb_mid'; $config[ 'width' ] = $this->sizes_mid[ 0 ]; $config[ 'height' ] = $this->sizes_mid[ 1 ]; $this->load->library( 'image_lib', $config ); $this->image_lib->resize(); $this->image_lib->clear(); $config[ 'thumb_marker' ] = '_thumb_small'; $config[ 'width' ] = $this->sizes_small[ 0 ]; $config[ 'height' ] = $this->sizes_small[ 1 ]; $this->image_lib->initialize( $config ); $this->image_lib->resize(); $this->upload_m->add( $this->upload->data() ); $this->success = '<p>La imagen ha sido subida correctamente</p>'; } } } } }