1
我有一張圖像,我從數據庫中作爲BLOB獲取,但是我發送客戶端的全尺寸圖像然後在其側面調整大小。圖像可能變得非常大,因此我想在將圖像發送到客戶端之前調整圖像大小。發送到客戶端之前在PHP中調整BLOB圖像的大小
目前,我有以下代碼:
if (!empty($row['img'])) {$img = $row['img'];}
$width = imagesx(imagecreatefromstring($img));
$height = imagesy(imagecreatefromstring($img));
$resizer = $width/200;
$newHeight = floor($height/$resizer);
$news = $news . "<div class='newsItem' style='min-height:".$newHeight."px;'>";
if (isset($img)) {$news = $news . "<img src='data:image/jpeg;base64,".base64_encode($img)."' width='200' height='".$newHeight."'>";}
$news = $news . "<h2>".$title."</h2><hr class='newsHr'><span>".$text."</span></div>";
我可以使用哪些功能來調整$ IMG?
嘿嘿,稍微糊塗在這裏。 $ filename會被引用到什麼地方? –
$ filename是對服務器上的圖像文件的引用。查看如何將BLOB轉換爲圖像文件的更新答案。 –