I want to resize images using codeigniter image manipulation class. I have tried a few things with no success. I have no errors after running the code below. After the image is uploaded using this code, I manually check to see if the image was resized but they are unchanged from the original size. Can anyone help with this? Is something wrong with the code below?
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class Edit_main_image extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function do_upload()
{
$config['upload_path'] = 'public/uploads/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('mainimg'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('templates/header');
$this->load->view('errorpage');
$this->load->view('templates/footer');
}
else
{
unlink($this->input->post('oldimage'));
$this->load->library('image_lib');
$this->image_lib->initialize($config);
$config['image_library'] = 'gd2';
$config['source_image'] = $config['upload_path'].$this->upload->data('file_name');
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 400;
$config['height'] = 350;