PHP Images
<?
include_once 'classes/class.db.php' ;
include_once '../p/inc.connect.php' ;
$str_query = "SELECT im.*, ib.blob_content, ib.blob_thumb
FROM image AS im
LEFT JOIN image_blob AS ib ON ( im.image_id = ib.image_id )
WHERE im.image_id = 1";
$arr_result = $obj_db -> execute_query ( $str_query, true );
$src = imagecreatefromstring( $arr_result[0]["blob_content"] ) ;
$dst = imagecreatetruecolor( 130, 130 ) ;
/*
bool imagecopyresampled (
resource dst_image, resource src_image,
int dst_x, int dst_y, int src_x, int src_y,
int dst_w, int dst_h, int src_w, int src_h
)
*/
$b = imagecopyresampled(
$dst, $src,
0, 0, 0, 0,
imagesx($dst) , imagesy($dst) , imagesx($src) , imagesy($src)
) ;
$tmpfname = tempnam( "/tmp", "jpeg" ) ;
imagejpeg( $dst , $tmpfname ) ;
$data = file_get_contents( $tmpfname ) ;
unlink( $tmpfname ) ;
header( "Content-Type: {$arr_result[0]["im_mimetype"]}" );
header( "Content-Length: {$arr_result[0]["size"]}" );
header( "Content-Transfer-Encoding: binary" );
echo $data ;
?>
include_once 'classes/class.db.php' ;
include_once '../p/inc.connect.php' ;
$str_query = "SELECT im.*, ib.blob_content, ib.blob_thumb
FROM image AS im
LEFT JOIN image_blob AS ib ON ( im.image_id = ib.image_id )
WHERE im.image_id = 1";
$arr_result = $obj_db -> execute_query ( $str_query, true );
$src = imagecreatefromstring( $arr_result[0]["blob_content"] ) ;
$dst = imagecreatetruecolor( 130, 130 ) ;
/*
bool imagecopyresampled (
resource dst_image, resource src_image,
int dst_x, int dst_y, int src_x, int src_y,
int dst_w, int dst_h, int src_w, int src_h
)
*/
$b = imagecopyresampled(
$dst, $src,
0, 0, 0, 0,
imagesx($dst) , imagesy($dst) , imagesx($src) , imagesy($src)
) ;
$tmpfname = tempnam( "/tmp", "jpeg" ) ;
imagejpeg( $dst , $tmpfname ) ;
$data = file_get_contents( $tmpfname ) ;
unlink( $tmpfname ) ;
header( "Content-Type: {$arr_result[0]["im_mimetype"]}" );
header( "Content-Length: {$arr_result[0]["size"]}" );
header( "Content-Transfer-Encoding: binary" );
echo $data ;
?>