在以下代码中,将 jpg 存储在 db 中,我需要知道如何首先将 jpg 更改为 40% 质量然后保存?我试过了imagejpg
,但它保存了空文件:
function exportGraphics($table_name)
{
$odbc_query = "SELECT * FROM " . $table_name;
mkdir("TI/" . $table_name);
$data = odbc_exec($this->odbc_id, $odbc_query);
odbc_longreadlen($data, 10485760); // 10MB = 10485760
while (odbc_fetch_row($data)) {
$row = odbc_fetch_array($data);
if ($row['GRD_ID'] != "") {
$file_name_jpg = "TI/" . $table_name . "/" . $row['GRD_ID'] . ".jpg";
$file = fopen($file_name_jpg, "w");
fputs($file, $row['GRD_GRAPHIC']);
fclose($file);
set_time_limit(3600);
unset($row);
}
}
print "Ýêñïîðò êàðòèíîê èç òàáëèöû " . $table_name . " çàâåðøåí!";
}
警告:imagecreatefromstring() [function.imagecreatefromstring]:gd 警告:内存分配乘法的一个参数为负数或零,在 X:\denwer\www\denwer\tecdoc3.php 第 103 行中优雅地失败操作
警告:imagecreatefromstring() [function.imagecreatefromstring]:在第 103 行的 X:\denwer\www\denwer\tecdoc3.php 中传递的数据不是“WBMP”格式
警告:imagecreatefromstring() [function.imagecreatefromstring]:Could't create GD Image Stream out of Data in X:\denwer\www\denwer\tecdoc3.php on line 103
警告:imagecreatefromstring() [function.imagecreatefromstring]:gd 警告:内存分配乘法的一个参数为负数或零,在 X:\denwer\www\denwer\tecdoc3.php 第 103 行中优雅地失败操作
原始代码:
function exportGraphics($table_name) {
$odbc_query = "SELECT * FROM " . $table_name;
mkdir("TI/" . $table_name);
$data = odbc_exec($this->odbc_id, $odbc_query);
odbc_longreadlen($data, 10485760); //10MB = 10485760
while(odbc_fetch_row($data))
{
$row = odbc_fetch_array($data);
if($row['GRD_ID'] != "") {
$file_name_jp2 = "TI/" . $table_name . "/" . $row['GRD_ID'] . ".jp2";
$file = fopen ($file_name_jp2, "w");
fputs($file, $row['GRD_GRAPHIC']);
fclose($file);
set_time_limit(0);
unset($row);
}
}
print "Ýêñïîðò êàðòèíîê èç òàáëèöû " . $table_name . " çàâåðøåí!";
}