Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何使用codeigniter和sql server 2005数据库从图像数据类型创建缩略图?_Image_Sql Server 2005_Codeigniter_Thumbnails - Fatal编程技术网

Image 如何使用codeigniter和sql server 2005数据库从图像数据类型创建缩略图?

Image 如何使用codeigniter和sql server 2005数据库从图像数据类型创建缩略图?,image,sql-server-2005,codeigniter,thumbnails,Image,Sql Server 2005,Codeigniter,Thumbnails,我正在使用最新的codeigniter框架和SQLServer2005开发web应用程序。在我的数据库中,我有一个表,表中有一列具有图像数据类型。从中,我知道如何使用以下内容检索该图像: $q = "Get_Picture_Test_SP @pk_rms_id=1443546"; $res = mssql_query($q); $row = mssql_fetch_assoc($res); $image = $row['picture']; function hex2bin($h) {

我正在使用最新的codeigniter框架和SQLServer2005开发web应用程序。在我的数据库中,我有一个表,表中有一列具有图像数据类型。从中,我知道如何使用以下内容检索该图像:

$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);
我仍然不知道如何从图像数据类型创建缩略图。希望有人能帮忙。谢谢

$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();
}

在您的代码中,您忘记了初始化配置。因此,请使用此代码,确保映像路径正确。希望这会起作用。

哦,是的,我忘了在我的问题中包括这一行。但我的问题实际上是如何不是从路径加载的图像中生成缩略图,而是从数据库中生成缩略图。我已经在我的问题中解释过了。我知道您想从db中的图像创建缩略图…您可以通过更改配置中的源路径来创建该图像的缩略图。。。。。。
$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();
}