CodeIgniter Forums
Image resizeing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Image resizeing (/showthread.php?tid=15716)



Image resizeing - El Forum - 02-12-2009

[eluser]rcoder[/eluser]
How to resize image which was fatch from DB??

Code:
$image_data = $this->db->get_where('idb_products', array('i_prod_id' => $id));
$row = $image_data->row();
$image = $row->i_prod_image;
/*   IMAGE RESIZE CODE WILL COME HERE */
$image_type = $row->i_prod_image_type;
header("Content-type: $image_type");
print $image;
exit();

Please help me to write image resize code...


Image resizeing - El Forum - 02-12-2009

[eluser]pistolPete[/eluser]
What are you storing in your database, just a filename or binary BLOB data?


Image resizeing - El Forum - 02-12-2009

[eluser]rcoder[/eluser]
[quote author="pistolPete" date="1234500735"]What are you storing in your database, just a filename or binary BLOB data?[/quote]

As a Binary BLOB data


Image resizeing - El Forum - 02-13-2009

[eluser]pistolPete[/eluser]
You have to subclass CI_Image_lib and rewrite the following functions (assuming you are using GD):
Code:
function image_process_gd($action = 'resize')
function image_create_gd($path = '', $image_type = '')

In your own image manipulation functions, you have to use imagecreatefromstring() to create an image from the database.

But I recommend storing the images as "real" files on your harddrive and insert just the filenames into the database!