Welcome Guest, Not a member yet? Register   Sign In
Image Manipulation Class - Resize Original AND Create Thumb???
#1

[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?
#2

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

[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
#4

[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.
#5

[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!
#6

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




Theme © iAndrew 2016 - Forum software by © MyBB