Welcome Guest, Not a member yet? Register   Sign In
Image resize issues - no errors
#1

[eluser]regal2157[/eluser]
Hi Guys,

I'm trying to do an image resize with codeigniter, but I'm not getting a resized image, nor am I getting any errors. Not sure if it is due to the lack of a library or not... Kinda lost..

This is my code:

Code:
<?php ...
$this->load->library('image_lib');
$img_lib_config['image_library']  = 'gd2';
$img_lib_config['source_image']   = $data['upload_data']['full_path'];
$img_lib_config['maintain_ratio'] = TRUE;
$img_lib_config['width']          = '320';
$img_lib_config['height']         = '280';

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

if(!$this->image_lib->resize())
{
echo $this->image_lib->display_errors();
die();
}
...
?>

Full path: /Applications/MAMP/htdocs/sample/backtomail/assets/folder/image/is/in/e9d4f858a3d16b0b7f76fbb76b60e0ef.jpg

I've also tried updating the source_image to be the relative path (/assets/folder/image/is/in/filename.ext)

Any ideas here fellow developers?

Thanks,
John
#2

[eluser]CroNiX[/eluser]
IIRC there is a bug where you can't instantiate that class with the config in one go. Try loading the library and then initializing it separately.
Code:
$this->load->library('image_lib');
$this->image_lib->initialize($img_lib_config);
#3

[eluser]regal2157[/eluser]
Cronix, you are still the man. Thanks for that! Glad you were able to remember that!
#4

[eluser]behnampmdg3[/eluser]
[quote author="CroNiX" date="1339457582"]IIRC there is a bug where you can't instantiate that class with the config in one go. Try loading the library and then initializing it separately.
Code:
$this->load->library('image_lib');
$this->image_lib->initialize($img_lib_config);
[/quote]I have the same problem, but your solution didnt help me Sad
Code:
$config['upload_path'] = SITE_PATH."images/events/";
$CI->photo_name = time().rand(1,10000000);
$config['file_name'] = $CI->photo_name.".jpg";
$config['allowed_types'] = 'gif|jpg|png';
$field_name = $photo;
$CI->load->library('upload');
$CI->upload->initialize($config);
if ( ! $CI->upload->do_upload($field_name))
{
  $error[] = array('error' => $CI->upload->display_errors());
}
$config['source_image'] = $config['upload_path'].$CI->photo_name.".jpg";
$config['overwrite'] = TRUE;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
if($photo=='thumbnail_photo')
{
  $config['width'] = 183;
  $config['height'] = 68;
}
else
{
  $config['width'] = 470;
  $config['height'] = 667;
}

$CI->load->library('image_lib');
$CI->image_lib->initialize($config);
if ( ! $CI->image_lib->resize())
{
  echo $CI->image_lib->display_errors();
}
else
{
  echo "Success";
  $data[$photo]=$CI->photo_name;
}




Theme © iAndrew 2016 - Forum software by © MyBB