CodeIgniter Forums
Image resize before upload - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Image resize before upload (/showthread.php?tid=57698)



Image resize before upload - El Forum - 04-03-2013

[eluser]davehedgehog[/eluser]
Hey, uh wonder if anyone could help? Im trying to upload an image and then create a smaller image and a thumb and store them in separete folders. As it stands the main image uploads but the smaller onse dont, shouldnt the image resize store the images to the new path?

Here is my do_upload in the controller~

Code:
public function do_upload()
{
  $this->load->library('image_lib');

  $config['upload_path'] = './uploads/blog/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '4442048';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

  $this->load->library('upload', $config);

  if ( ! $this->upload->do_upload())
  {
   $this->form_validation->set_message('do_upload', $this->upload->display_errors(), 'Dodgy Blog entry :/');
   return FALSE;
  }
  else
  {
   $data = array('upload_data' => $this->upload->data());
  
   $config['image_library'] = 'gd2';
   $config['source_image'] = $data['Image'];
   $config['new_image'] = './uploads/blog/last/';
   $config['create_thumb'] = 'TRUE';
   $config['maintain_ratio'] = 'TRUE';
   $config['width'] = '400';
   $config['height']  = '300';

   $this->load->initialize($config);
   $this->image_lib->resize();  

   $config['image_library'] = 'gd2';
   $config['source_image'] = $data['Image'];
   $config['new_image'] = './uploads/blog/thumb/';
   $config['create_thumb'] = 'TRUE';
   $config['maintain_ratio'] = 'TRUE';
   $config['width'] = '36';
   $config['height']  = '36';

   $this->load->initialize($config);
   $this->image_lib->resize();
  
   if ( ! $this->image_lib->resize())
   {
    echo $this->image_lib->display_errors();
    $this->session->set_flashdata('flashError', 'No smaller images stored :/');
   }
  }
}



Image resize before upload - El Forum - 04-03-2013

[eluser]Sanjay Sarvaiya[/eluser]
Hi,
Every thing looks like perfect. make sure that resize image directory is writable.
Code:
..
//set create_thumb false;
$config['create_thumb'] = 'FALSE';
...
//Add below line before initialize resize $config variables.
$this->image_lib->clear();
$this->load->initialize($config);
....
//$this->image_lib->resize();
  
   if ( ! $this->image_lib->resize())
   {
...


hopes that's help.


Image resize before upload - El Forum - 04-03-2013

[eluser]jairoh_[/eluser]
[quote author="Sanjay Sarvaiya" date="1365052548"]Hi,
Every thing looks like perfect. make sure that resize image directory is writable.
Code:
..
//set create_thumb false;
$config['create_thumb'] = 'FALSE';
...
//Add below line before initialize resize $config variables.
$this->image_lib->clear();
$this->load->initialize($config);
....
//$this->image_lib->resize();
  
   if ( ! $this->image_lib->resize())
   {
...


hopes that's help.[/quote]
how to know or make the resize image rewritable?


Image resize before upload - El Forum - 04-04-2013

[eluser]Sanjay Sarvaiya[/eluser]
you miss understood I mean that resize image "directory" not that resize image!




Image resize before upload - El Forum - 04-05-2013

[eluser]davehedgehog[/eluser]
Yeah all 0777, keep getting this~ I still cant get the image resize to work, even if I change the new source config, still get the conflict with ion auth :/

any idea why? this is the error~

An Error Was Encountered

The model name you are loading is the name of a resource that is already being used: ion_auth_model




Image resize before upload - El Forum - 04-05-2013

[eluser]Sanjay Sarvaiya[/eluser]
can u show me what error is getting.


Image resize before upload - El Forum - 04-07-2013

[eluser]davehedgehog[/eluser]
An Error Was Encountered

The model name you are loading is the name of a resource that is already being used: ion_auth_model


Image resize before upload - El Forum - 04-09-2013

[eluser]Sanjay Sarvaiya[/eluser]
Error say that ion_auth_model already loaded. you can load model once.


Image resize before upload - El Forum - 04-10-2013

[eluser]NtesTechnologies[/eluser]
There are two ways of using it:

By using <input type=”file”> and its change event
By dragging and dropping files from your computer directly in the browser


Image resize before upload - El Forum - 05-05-2013

[eluser]hebe_210[/eluser]
resize Images example ,any suggestions?

public static void ResizeImageDemo()
{
string fileName = "c:/Sample.png";

REImage reImage = REFile.OpenImageFile(fileName);

ImageProcessing.applyResize(reImage, 500, 500);

REFile.SaveImageFile(reImage,"c:/reimage.png", new PNGEncoder()Wink;
}