CodeIgniter Forums
rotate large images not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: rotate large images not working (/thread-54596.html)



rotate large images not working - El Forum - 09-16-2012

[eluser]pinarella[/eluser]
i have a problem in codeigniter when rotating large images...bigger than 1.2mb. for smaller images, there is no problem. is there any solution?

here is the code:

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';
    }
}




rotate large images not working - El Forum - 09-17-2012

[eluser]rogierb[/eluser]
What kind of error are you getting?

My guess its a problem with memory allocation when rotating a large jpg.
With GD or GD2 the memory consumption when processing a jpg is huge. The reason for this is it unpackes a JPG, performes the operation and then repacks the image.

I've seen memory consumption over 512 MB.
You can set your memory_limit to a higher number or use ImageMagick for instance.




rotate large images not working - El Forum - 09-17-2012

[eluser]pinarella[/eluser]
yes, i have discovered it from hosting logs.
current hosting provider sets memory limit to 32mb.

i can maybe resize images to under 2000x1600 and then rotate them, because i dont need high res images.

do you have a link on how to do the rotation with imagemagick?

thanks


rotate large images not working - El Forum - 09-17-2012

[eluser]rogierb[/eluser]
Just change your settings to use ImageMagick instead of GD2

Code:
$config['image_library'] = 'ImageMagick';



rotate large images not working - El Forum - 09-18-2012

[eluser]pinarella[/eluser]
thanks, it worked like a charm.