// controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Thumb extends CI_Controller {
function __construct()
{
parent::__construct();
}
function thumb_test() {
$this->load->helper('thumb');
make_thumb();
}
}
//helper
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function make_thumb(){
$config['image_library'] = 'gd2';
$config['source_image'] = './static/upload/image/original/148207021533.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$config['thumb_maker'] = "thumb_";
//print_r($config);
$this->load->library('image_lib', $config);
//$this->image_lib->initialize($config);
$this->image_lib->resize();
//$this->image_lib->clear();
}
image_lib 를 이용해서 help를 만드려고 합니다.
$this->load->library('image_lib', $config); 이부분에서 500에러가 납니다.
이미지 섬네일 생성하는 부분을 helper를 이용하지 않고 controll에서 바로 실행할때는 아무런 문제가 없는데 helper를 이용하니 문제가 생기네요. 고수님들 답변 좀 부탁드려요 (__ );
helper 파일에 있는 내용을 그대로 cotroller에 가져다 넣으면 잘 실행이 되거든요.
helper에만 들어가면 오류가 발생하네요
library 로드하는 방법이 틀렸습니다.
아래처럼 바꾸세요.
$this->load->library('image_lib'); $this->image_lib->initialize($config);