Welcome Guest, Not a member yet? Register   Sign In
image manipulation, cycled operations stop at 3 iterations.
#1

[eluser]smick[/eluser]
Hi!

So I've encountered a pretty nasty problem doing image resizing. It works up to 3 iterations, then stops outputting images. The script is not necessarily failing since the code below the resize code it processing, but that said, even in it's simplest form, the script still fails to process after 3 iterations.

notes:

image size doesn't seem to matter, if I upload an icon sized imae it still stops at 4 iterations.

If I reorder the image resize scripts, it still stops at 3 iterations.

I've tried raising the time out limit in .htaccess with no results

I've tried raising the timeout limit in php before running the scripts, then flushing it after with no effects.

I'm using the clear() and initialize() functions after image processing.

my code:

Code:
//create med version of image (400 max-width)
$config['image_library'] = 'gd2';
$config['source_image'] = 'assets/images/gallery/' . $data['upload_data']['file_name'];
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_med_400" . $data['upload_data']['file_ext'];
$config['maintain_ratio'] = TRUE;
$config['height'] = 30000;
if($data['upload_data']['image_width'] > 400) { $config['width'] = 400; }
else {                                             $config['width'] = $data['upload_data']['image_width']; }
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$this->image_lib->initialize($config);

//create large version of image (550px max-height)
$config['image_library'] = 'gd2';
$config['source_image'] = 'assets/images/gallery/' . $data['upload_data']['file_name'];
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_large_550" . $data['upload_data']['file_ext'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 30000;
if($data['upload_data']['image_height'] > 550) { $config['height'] = 550; }
else {                                             $config['height'] = $data['upload_data']['image_height']; }
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$this->image_lib->initialize($config);




//create small version of image (100 max-width)
$config['image_library'] = 'gd2';
$config['source_image'] = 'assets/images/gallery/' . $data['upload_data']['file_name'];
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_thumb_100" . $data['upload_data']['file_ext'];
$config['maintain_ratio'] = TRUE;
$config['height'] = 30000;
if($data['upload_data']['image_width'] > 100) { $config['width'] = 100; }
else {                                             $config['width'] = $data['upload_data']['image_width']; }
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$this->image_lib->initialize($config);

//create small version of image (150 max-width)
$config['image_library'] = 'gd2';
$config['source_image'] = 'assets/images/gallery/' . $data['upload_data']['file_name'];
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_thumb_150" . $data['upload_data']['file_ext'];
$config['maintain_ratio'] = TRUE;
$config['height'] = 30000;
if($data['upload_data']['image_width'] > 150) { $config['width'] = 150; }
else {                                             $config['width'] = $data['upload_data']['image_width']; }
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$this->image_lib->initialize($config);


I'm holding up the project trying to get this working, so any help is a bailout as far as I'm concerned and very appreciated!

Thanks,
#2

[eluser]Tominator[/eluser]
Why do you set height or width to 30000? Isn't it too much?

Try this (with 30000), if it will not work try clear() or delete height/width = 30000.

This is smaller version:
Code:
$this->load->library('image_lib');

//create med version of image (400 max-width)
$config['image_library'] = 'gd2';
$config['source_image'] = 'assets/images/gallery/' . $data['upload_data']['file_name'];
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_med_400" . $data['upload_data']['file_ext'];
$config['maintain_ratio'] = TRUE;

$config['height'] = 30000;
$config['width'] = ($data['upload_data']['image_width'] > 400) ? 400: $data['upload_data']['image_width'];

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

//create large version of image (550px max-height)
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_large_550" . $data['upload_data']['file_ext'];

$config['width'] = 30000;
$config['height'] = ($data['upload_data']['image_height'] > 550) ? 550 : $data['upload_data']['image_height'];

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


//create small version of image (100 max-width)
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_thumb_100" . $data['upload_data']['file_ext'];
$config['height'] = 30000;
$config['width'] = ($data['upload_data']['image_width'] > 100) ? 100 : $data['upload_data']['image_width'];

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


//create small version of image (150 max-width)
$config['new_image'] = 'assets/images/gallery/' . $data['upload_data']['raw_name'] . "_thumb_150" . $data['upload_data']['file_ext'];
$config['height'] = 30000;
$config['width'] = ($data['upload_data']['image_width'] > 150) ? 150 : $data['upload_data']['image_width'];

$this->image_lib->initialize($config);
$this->image_lib->resize();
#3

[eluser]smick[/eluser]
hmm. That didn't work either. I read somewhere that you're supposed to call initialize() after you call clear() and the CI docs show setting the config when you load the library.

Man this is frustrating. It's working, just it stops working after 3 iterations. What could it be? Could it be a memory limit? Wouldn't that throw a warning or error?
#4

[eluser]Tominator[/eluser]
Would it be working, when you not set height and width to 30.000 ?
I think it can be problem with memory, because, it's probably saving images until PHP script ends. That means you are saving 3 images with resolution 30.000 => it's some MegaPixels ...




Theme © iAndrew 2016 - Forum software by © MyBB