Upload, Crop, Resize, and Thumb - Printable Version
+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Upload, Crop, Resize, and Thumb (/showthread.php?tid=25438)
|
Upload, Crop, Resize, and Thumb - El Forum - 12-11-2009
[eluser]merrick.christensen[/eluser]
Ok. I'm not sure what the heck is going on here. I am getting very frustrated and would appreciate any help hat could be offered.
The user is uploading an image. It sends them to a crop utility, they crop and it resizes, then it would create a thumb from the crop. My issue is that it is applying the thumb resize to the crop rather then creating a new one. Even thought the property is set, in fact if I access the process_thumb function directly it will create a thumb, but not with PHP. Any help would be so appreciated.
Code: <?php
function process_image($image_url)
{
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/' . $image_url;
$config['maintain_ratio'] = FALSE;
$config['width'] = $this->input->post('w');
$config['height'] = $this->input->post('h');
$config['x_axis'] = $this->input->post('x');
$config['y_axis'] = $this->input->post('y');
$this->image_lib->initialize($config);
if ( ! $this->image_lib->crop())
{
echo $this->image_lib->display_errors();
}
else {
if (! $this->process_resize($image_url)){
echo "Failed Resize";
} else{
if(! $this->process_thumb($image_url)){
echo "Failed Thumb";
} else{
echo "success";
}
}
}
}
function process_resize($image_url)
{
$this->image_lib->clear();
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/' . $image_url;
$config['maintain_ratio'] = TRUE;
$config['width'] = 162;
$config['height'] = 246;
$this->image_lib->initialize($config);
if ( ! $this->image_lib->resize()){
return false;
} else{
return true;
}
}
function process_thumb($image_url)
{
$this->image_lib->clear();
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/' . $image_url;
$config['maintain_ratio'] = TRUE;
$config['create_thumb'] = TRUE;
$config['width'] = 32;
$config['height'] = 32;
$this->image_lib->initialize($config);
//I resize and all that goodness
if(! $this->image_lib->resize()){
//echo $this->image_lib->display_errors();
return false;
} else{
//echo "Nice";
return true;
}
}
Upload, Crop, Resize, and Thumb - El Forum - 12-11-2009
[eluser]Krzemo[/eluser]
I cant see
Code: $config['new_image'] = '/path/to/new_image.jpg';
anywhere in your code...
Upload, Crop, Resize, and Thumb - El Forum - 12-12-2009
[eluser]Isern Palaus[/eluser]
You can take a look to the library Images posted by JoostV:
http://codeigniter.com/wiki/Category:Libraries::Images/
|