title: how to create thumbnail from image datatype with codeigniter and sql server 2005 database?
body: <p>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 <a href="https://stackoverflow.com/questions/2630711/help-reading-binary-image-data-from-sql-server-into-php">here</a> I know how to retrieve that image with this : </p>
  
  <pre><code>$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&lt;strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); }
      return $r;
   }
  
  $image = hex2bin($image);
  </code></pre>
  
  <p>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 :</p>
  
  <pre><code>$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-&gt;load-&gt;library('image_lib', $config); 
  
   $this-&gt;image_lib-&gt;resize();
  </code></pre>
  
  <p>I still dont know how to creating thumbnail from image data type. Hope anyone can help. Thanks!</p>