In the following code, that stores a jpg in db, I need to know how to first change the jpg to 40% quality and then save? i tried with imagejpg, but it saves null-files:
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 . " çàâåðøåí!";
}
Warning: imagecreatefromstring() [function.imagecreatefromstring]: gd
warning: one parameter to a memory allocation multiplication is
negative or zero, failing operation gracefully in
X:\denwer\www\denwer\tecdoc3.php on line 103Warning: imagecreatefromstring() [function.imagecreatefromstring]:
Passed data is not in ‘WBMP’ format in
X:\denwer\www\denwer\tecdoc3.php on line 103Warning: imagecreatefromstring() [function.imagecreatefromstring]:
Couldn’t create GD Image Stream out of Data in
X:\denwer\www\denwer\tecdoc3.php on line 103Warning: imagecreatefromstring() [function.imagecreatefromstring]: gd
warning: one parameter to a memory allocation multiplication is
negative or zero, failing operation gracefully in
X:\denwer\www\denwer\tecdoc3.php on line 103
original code:
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 . " çàâåðøåí!";
}
Try this:
Or is that exactly what you tried?
If for some reason that doesn’t work, you can try:
EDIT: The reason GD isn’t working is because it doesn’t support JPEG-2000 file format
Possible solution: Install
imagemagickon the server and try code like this: