Welcome Guest, Not a member yet? Register   Sign In
Image Manipulation class dies on JPEGs larger than 1938x2911
#1

[eluser]cairo140[/eluser]
I use the file upload class and image manipulation library. The manipulation function
Code:
$this->image_lib->resize()
works fine on JPEGs up to 1938x2911 (width x height), but if you increase either one by another pixel it doesn't work. File size doesn't seem to matter. When I say it doesn't work, I mean the server just returns a 500 error with no content (no PHP errors or anything). It just rolls over and dies. Here's the code:

Code:
$config['upload_path'] = './uplimg/avatars';
$config['max_size'] = 1048;
$config['allowed_types'] = 'gif|jpg|jpeg|png';
        
$this->load->library('upload', $config);

if($this->upload->do_upload('avatar')) {
  $upload_data = $this->upload->data();
  $filename = $upload_data['file_name'];
  $filepath = $upload_data['full_path'];

  $config = array();
  $config['image_library'] = 'gd2';
  $config['source_image'] = $filepath;
  $config['width'] = 100;
  $config['height'] = 100;
  $config['maintain_ratio'] = true;
  $config['master_dim'] = 'auto';
  $this->load->library('image_lib', $config);                
            
  var_dump($this->image_lib->resize()); // for outputting result
        
}

The resize function should return a true on success or false on failure, but if I upload a "bad" image, the server just 500s and does not show anything.

I tried this on another server and cannot duplicate the results. I do not have a config file in application/config for either library. Help?
#2

[eluser]Colin Williams[/eluser]
Quote:I tried this on another server and cannot duplicate the results

Then I think you need to look at your server error logs and see what's up, or get a server administrator to help you out.q
#3

[eluser]cairo140[/eluser]
Which error logs should I look for? It's running a regular LAMP. I can get to pretty much anything through SSH.
#4

[eluser]Colin Williams[/eluser]
something like apache/logs/error.log. It's configurable with the ErrorLog directive, so it could exist anywhere.
#5

[eluser]cairo140[/eluser]
I found something at /etc/httpd/logs/error_log but it didn't have any entries since Tuesday. There was also an access_log but it was just filled with internal dummy connections. I found access_log and error_log in Plesk specific to the domain.

Searching for the specific connection in the access_log just yields my IP address then 500.
The error_log has a number of errors but nothing at the time of my error.
#6

[eluser]janogarcia[/eluser]
Hi cairo140, I had a similiar problem long ago. It was caused by the PHP memory_limit directive.

A JPG image of about 2MB would eat up about 20MB of server memory when decompressed by the GD library. memory_limit was set to 16MB, so the script failed silently, no error displayed.
#7

[eluser]cairo140[/eluser]
[quote author="janogarcia" date="1260542864"]Hi cairo140, I had a similiar problem long ago. It was caused by the PHP memory_limit directive.

A JPG image of about 2MB would eat up about 20MB of server memory when decompressed by the GD library. memory_limit was set to 16MB, so the script failed silently, no error displayed.[/quote]

Brilliant! Great idea that I didn't think of. Odd how this doesn't generate an error message. My memory limit was set as 32 MB actually, but it evidently still wasn't enough. I upped it to 64 MB and all works fine! Smile
#8

[eluser]janogarcia[/eluser]
Nice! Glad to be of help.

Maybe I should suggest adding it as a warning note on the Image Library documentation (as CI's documentation doesn't allow user comments).




Theme © iAndrew 2016 - Forum software by © MyBB