В настоящее время я работаю над библиотекой мультимедиа для веб-сайта, и одна из функций заключается в том, что пользователь может создать обрезанную версию загружаемого ими изображения.
Однако моя проблема заключается в следующем, когда япопробуйте обрезать изображение, я получаю следующую ошибку,
The path to the image is not correct.
Вот мой код,
$config['image_library'] = 'gd2';
$config['source_image'] = "/media/images/products/".$this->data['image'];
//die($config['source_image']);
$config['maintain_ratio'] = FALSE;
$config['x_axis'] = $this->input->post('x');
$config['y_axis'] = $this->input->post('y');
$config['width'] = $this->input->post('w');
$config['height'] = $this->input->post('h');
$config['dynamic_output'] = FALSE;
$config['create_thumb'] = TRUE;
$this->load->library('image_lib', $config);
if(!$this->image_lib->crop()) {
if($this->input->post('isAjax') == "1") {
echo json_encode($this->image_lib->display_errors());
} else {
$this->data['image_error'] = $this->image_lib->display_errors();
$this->template->build('/admin/media/crop', $this->data);
}
} else {
$filename = base_url()."media/images/products/".$this->data['image'];
$extension_pos = strrpos($filename, '.'); // find position of the last dot, so where the extension starts
$thumb = substr($filename, 0, $extension_pos) . '_thumb' . substr($filename, $extension_pos);
if($this->input->post('isAjax') == 1) {
echo json_encode($success = array('message' => 'Image Cropped'));
} else {
$this->data['success'] = "Image Cropped";
$this->template->build('/admin/media/crop', $this->data);
}
}
Так что я хотел бы изменить $config['source_image']
на следующее,
$config['source_image'] = "./media/images/products/".$this->data['image'];
однако, что только уходит с этим сообщением,
Your server does not support the GD function required to process this type of image.
Я делаю что-то в корне неправильно?Я только пытаюсь обрезать простой файл .png, и файл, безусловно, существует на моем сервере, и у меня определенно установлен GD2.