1

i have a problem in codeigniter rotating large images...bigger than 1.2mb. for smaller images, there is no problem.

here is the code:

public function rotate(){
    $path = $this->input->post('path');
    $file = $this->input->post('file');
    $config['image_library'] = 'gd2';
    $config['source_image'] = $path;
    $config['rotation_angle'] = '90';
    $config['new_image'] = './uploads/_rot'.$file;
    $this->load->library('image_lib');

    $this->image_lib->initialize($config); 
    //$this->image_lib->rotate();
    if(!$this->image_lib->rotate()){
        echo $this->image_lib->display_errors();
    } else {
        echo 'OK';
    }
}
Taz
  • 3,718
  • 2
  • 37
  • 59
pinarella
  • 805
  • 8
  • 16

2 Answers2

1

This can be due to low memory_limit setting in PHP core (you can verify it with phpinfo()) and the memory consumption by GD2 library.
You can consult these two questions on fixing that:

You can also give it a try with ImageMagic library:

$config['image_library'] = 'imagemagick';
$config['library_path'] = '/usr/bin/convert';

Make sure it's installed before.

Community
  • 1
  • 1
Taz
  • 3,718
  • 2
  • 37
  • 59
1

i have located the problem. thanks Struna. my hosting provider have set php memory limit to 32mb and gd2 libs are hungry for mem, and they are not going to increase it, solution is to migrate or another library: imagemagick :) here is the code and it works great

public function rotate(){
    $path = $this->input->post('path');
    $file = $this->input->post('file');
    //echo "aaa";
    $config['image_library'] = 'imagemagick';
    $config['library_path'] = '/usr/bin';       
    $config['source_image'] = $path;
    $config['rotation_angle'] = '90';
    $config['quality'] = "90%";     
    $config['new_image'] = './uploads/_rot'.$file;
    $this->load->library('image_lib');
    $this->load->helper('file');

    $this->image_lib->initialize($config); 
    //$this->image_lib->rotate();
    if(!$this->image_lib->rotate()){
        echo $this->image_lib->display_errors();
    } else {
        echo 'OK';
        //delete_files($path);
    }
}
pinarella
  • 805
  • 8
  • 16
  • Great. [You can accept your own answer](http://meta.stackexchange.com/questions/12513/should-i-not-answer-my-own-questions) since your solution solves the problem. – Taz Sep 23 '12 at 15:37