Welcome Guest, Not a member yet? Register   Sign In
Resize image
#1

[eluser]Unknown[/eluser]
I trying to resize a image in execution mode...

my helper
Code:
<?php

function generate_image($img, $imgName, $width, $height){

        $obj =& get_instance();

        $obj->load->library('image_lib');
        $obj->load->helper('url');

        $config['image_library'] = 'gd2';
        $config['source_image'] = $img;
        $config['new_image'] = './temp/images/' . $imgName;
        $config['width'] = $width;
        $config['height'] = $height;
  
        $obj->image_lib->initialize($config);
        $obj->image_lib->resize();

  return $config['new_image'];
    }

?>

my view
this code below is in a foreach
Code:
$img = 'images/noticias/' . $item->foto;
$imgName = $item->foto;
$width = 680;
$height = 380;
echo "<img src='" . generate_image($img, $imgName, $width, $height) . "' />";

but doesn't work

this code returns
Code:
<img src='./temp/images/2a48f94f37851549b729105d7de8e1e3.jpg' />
but this "new image" don't exists...




Theme © iAndrew 2016 - Forum software by © MyBB