Resize () does not work using image manipulation class

I read documents and try to do my best to make thumbs up from uploaded images, but I can not find the problem.

Images are loaded and saved correctly, but there are no thumbs, it does not work without error output. This is Im code using:

$data = $this->upload->data();

$config_image['image_library'] = 'gd';
$config_image['source_image'] = $data['full_path'];
$config_image['new_image'] = 'uploads/thumbs/';
$config_image['create_thumb'] = TRUE;
$config_image['maintain_ratio'] = TRUE;
$config_image['width'] = 750;
$this->load->library('image_lib', $config_image);

if ( !$this->image_lib->resize())
{
    $this->session->set_flashdata('message',  $this->image_lib->display_errors());
} 

In addition, I want to resize the images to fit max-width = 750, but keep the ratio. Is Im Right To Achieve This? Thank!

0
source share
5 answers

I know this is too late, but I recently had the same problem and solved it by initializing the class.

CodeIgniter , :

$this->load->library('image_lib');

:

$this->image_lib->initialize($config);

.

, - , CodeIgniter, .

+1

, , ? ( ).

, , , :

$target_width = 750;
$image_aspect_ratio = $image_width / $image_height;
$target_height = $target_width / $image_aspect_ratio;

: r = w/h. , w = r * h (= , ) h = w/r (= , ).

+1

GD2.

CI . , timthumb. 1 PHP , " " . src . , , CI.

+1

$config_image['new_image'] = 'uploads/thumbs/'; $config['image_library'] = 'gd'; $config['image_library'] = 'gd2';

, $data _.

0

: ? : CIs , -.

0
source

Source: https://habr.com/ru/post/1777955/


All Articles