CodeIgniter Forums
Image Manipulation Class - Resize Original AND Create Thumb??? - 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: Image Manipulation Class - Resize Original AND Create Thumb??? (/thread-9961.html)



Image Manipulation Class - Resize Original AND Create Thumb??? - El Forum - 07-14-2008

[eluser]Muppit[/eluser]
According to the docs:

Quote:$this->image_lib->resize()
The image resizing function lets you resize the original image, create a copy (with or without resizing), or create a thumbnail image.

it would seem the image manipulation class won't actually resize the original image, AND create a thumbnail from it??? I've tried using various options with no success.

Is this correct? In which case, I'd have to resize the image and create a thumbnail from it, then go back and resize the original without creating a thumbnail...seems like a seriously roundabout way of doing it.

Is this right or am I missing the mark?


Image Manipulation Class - Resize Original AND Create Thumb??? - El Forum - 07-14-2008

[eluser]xpix[/eluser]
I think you have to call the resize function 2 times with diffrent configurations.


Image Manipulation Class - Resize Original AND Create Thumb??? - El Forum - 07-14-2008

[eluser]Muppit[/eluser]
Yeah that's what I've managed to work out so far, using a two step loop with diff. configs each round, I was just hoping there might be something I was missing that meant the original was resized in the process...thanks for the reply xpix


Image Manipulation Class - Resize Original AND Create Thumb??? - El Forum - 07-14-2008

[eluser]Muppit[/eluser]
Well after much head scratching here's my solution to this problem:

Code:
$this->load->library('image_lib');

//[ THUMB IMAGE ]
$img_config_0['image_library'] = 'GD';
$img_config_0['source_image'] = '../images/portfolio/' . $thisFile;
$img_config_0['maintain_ratio'] = TRUE;
$img_config_0['width'] = 200;
$img_config_0['height'] = 200;    
$img_config_0['create_thumb'] = TRUE;
                            
//[ MAIN IMAGE ]
$img_config_1['image_library'] = 'GD';
$img_config_1['source_image'] = '../images/portfolio/' . $thisFile;
$img_config_1['maintain_ratio'] = TRUE;
$img_config_1['width'] = 1000;
$img_config_1['height'] = 1000;
$img_config_1['create_thumb'] = FALSE;
                    
for($i=0;$i<2;$i++){              eval("\$this->image_lib->initialize(\$img_config_".$i.");");
if($this->image_lib->resize()){
echo "Success";                                
}else{
echo "Failed." .$i . $this->image_lib->display_errors();
}
}

Seems to be the fastest way of doing things. It will iterate through twice, each time loading in the right config array, of which the first one will generate a thumb from the specified image, and the second, resize that original image.

Hope it helps anyone having the same issue.


Image Manipulation Class - Resize Original AND Create Thumb??? - El Forum - 10-24-2010

[eluser]Unknown[/eluser]
[quote author="Muppit" date="1216092518"]Well after much head scratching here's my solution to this problem:

Code:
$this->load->library('image_lib');

//[ THUMB IMAGE ]
$img_config_0['image_library'] = 'GD';
$img_config_0['source_image'] = '../images/portfolio/' . $thisFile;
$img_config_0['maintain_ratio'] = TRUE;
$img_config_0['width'] = 200;
$img_config_0['height'] = 200;    
$img_config_0['create_thumb'] = TRUE;
                            
//[ MAIN IMAGE ]
$img_config_1['image_library'] = 'GD';
$img_config_1['source_image'] = '../images/portfolio/' . $thisFile;
$img_config_1['maintain_ratio'] = TRUE;
$img_config_1['width'] = 1000;
$img_config_1['height'] = 1000;
$img_config_1['create_thumb'] = FALSE;
                    
for($i=0;$i<2;$i++){              eval("\$this->image_lib->initialize(\$img_config_".$i.");");
if($this->image_lib->resize()){
echo "Success";                                
}else{
echo "Failed." .$i . $this->image_lib->display_errors();
}
}

Seems to be the fastest way of doing things. It will iterate through twice, each time loading in the right config array, of which the first one will generate a thumb from the specified image, and the second, resize that original image.

Hope it helps anyone having the same issue.[/quote]

Thanks! Simple but efficient solution!


Image Manipulation Class - Resize Original AND Create Thumb??? - El Forum - 10-24-2010

[eluser]Sire[/eluser]
Old topic, but thought you might be interested in this too
http://www.matmoo.com/digital-dribble/codeigniter/image_moo/