[eluser]Unknown[/eluser]
Hi I've the following problem
I upload one image in the directory ./images/originals
Then I want to resize this image to a compacter format. Therfore i resize it and create with the $config['new_image'] attribute a compact version in ./images/compact
After this i resize the original image to create a thumbnail version. Therfore i resize it with the $config['new_image'] attribute to create the thumbnail in ./images/thumbnails
The problem is that after the upload the thumbnail is created but the compact version is not. I don't know why. Maybe you can help me?
Here is the code
Code:
function save() {
$config ['upload_path'] = './images/originals/';
$config ['allowed_types'] = 'gif|jpg|png|jpeg';
$config ['max_size'] = '2048';
$config ['max_width'] = '0';
$config ['max_height'] = '0';
$this->load->library ( 'upload', $config );
if ($this->upload->do_upload ()) {
$data = array ('upload_data' => $this->upload->data () );
$this->create_thumb( $data ['upload_data'] ['file_name'] ); // Thumbnail creation
$this->create_compact( $data ['upload_data'] ['file_name'] ); // compact version creation
} else {
$error = array ('error' => $this->upload->display_errors () );
$this->load->view ( 'upload_form', $error );
}
}
function create_thumb($filename) {
if(!is_dir("./images/thumbnails/".$this->user))
mkdir("./images/thumbnails/".$this->user, 0777);
$config ['image_library'] = 'GD';
$config ['thumb_marker'] = '';
$config ['source_image'] = './images/originals/' . $filename;
$config ['new_image'] = './images/thumbnails/thumb_' . $filename;
$config ['create_thumb'] = TRUE;
$config ['maintain_ratio'] = TRUE;
$config ['width'] = 100;
$config ['height'] = 100;
$this->load->library ( 'image_lib', $config );
if ($this->image_lib->resize ()) {
$data = array ('image' => $config ['new_image'] );
} else {
$data = array ('error' => $this->image_lib->display_errors () );
}
$this->load->view ( 'images_show', $data );
}
function create_compact($filename) {
$config ['image_library'] = 'GD';
$config ['quality'] = '80%';
$config ['source_image'] = './images/originals/' . $filename;
$config ['new_image'] = './images/compact/c' . $filename;
$config ['maintain_ratio'] = TRUE;
$config ['width'] = 800;
$config ['height'] = 600;
$this->load->library ( 'image_lib', $config );
$this->image_lib->resize ();
}