0

I'm developing web application using latest codeigniter framework and SQL Server 2005. In my database, i have a table that have a column wth image datatype. From here I know how to retrieve that image with this :

$q = "Get_Picture_Test_SP @pk_rms_id=1443546";
$res = mssql_query($q);

$row = mssql_fetch_assoc($res);

$image = $row['picture'];

function hex2bin($h)
{
    if (!is_string($h)) return null;
    $r='';
    for ($a=0; $a<strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); }
    return $r;
 }

$image = hex2bin($image);

What i want to know is how can i make a thumbnail from that image to make the web loading more fast? If I use image from some path i know how to make the thumbnail (hope i not wrong) with this :

$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']     = 75;
$config['height']   = 50;

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

 $this->image_lib->resize();

I still dont know how to creating thumbnail from image data type. Hope anyone can help. Thanks!

1 Answer 1

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

$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']     = 75;
$config['height']   = 50;

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

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

In your code your forget to initialize the config..So please use this code make sure the image path is correct..Hopefully this will work.

Sign up to request clarification or add additional context in comments.

2 Comments

oh yes, i forget to including that line in my question. But my problem is actually how to make thumbnail not from image that i load from a path, but from database. I already explained it in my question..
I know that you want to create thumbnails from the image which you have in db...You can create thumbnail of that image by just changing the source path in the config......

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.