• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image resize before upload

#1
[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 :/');
   }
  }
}

#2
[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.

#3
[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?

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


#5
[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


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

#7
[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

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

#9
[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

#10
[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;
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.