請幫助我解決我當前的功能,使其成功地將任何其他圖像類型轉換為正確的 jpg 圖像類型。這是我的功能 function resize_image($oldimage_name, $new_image_name){ list($owidth,$oheight) = getimagesize($oldimage_name); $width = 250; $height = 250; $im = imagecreatetruecolor($width, $height); $img_src = imagecreatefromjpeg($oldimage_name); imagealphablending($img_src, false); imagesavelalpha($img_src, true); imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight); imagejpeg($im, $new_image_name, 90); imagedestroy($im); unlink($oldimage_name); return true;}感謝您的寶貴時間并提前提供幫助
1 回答

德瑪西亞99
TA貢獻1770條經驗 獲得超3個贊
如果它不是 jpg,您將失敗。請改用imagecreatefromstring()。這樣就可以猜出真正的格式了。
像這樣替換代碼
$img_src?=?imagecreatefromstring(file_get_contents($oldimage_name));
- 1 回答
- 0 關注
- 152 瀏覽
添加回答
舉報
0/150
提交
取消