按給我的任務,我想看看PHP的以下兩個功能的效果上的圖像文件 1. imagecreatefromjpeg 2. imagejpeg問題使用imagecreatefromjpeg和imagejpeg
我上傳的文件使用HTML,然後我的PHP代碼如下所示:
<?php
try{
if(!$image=imagecreatefromjpeg('zee1.jpg')){
throw new Exception('Error loading image');
}
// create text color for jpg image
if(!$textColor=imagecolorallocate($image,0,255,0)){
throw new Exception('Error creating text color');
}
// include text string into jpg image
if(!$text=imagestring($image,5,10,90,'This is a sample text
string.',$textColor)){
throw new Exception('Error creating image text');
}
header("Content-type:image/jpeg");
// display image
imagejpeg($image, 'zee1After.jpg');
// free up memory
imagedestroy($image);
}
catch(Exception $e){
echo $e->getMessage();
exit();
}
?>
但是,當我這樣做,我得到下面的輸出:
致命錯誤:用盡33554432個字節允許內存大小(試圖在第3行的C:\ Users \ zee \ Documents \ Flex Builder 3 \ CLOUD \ bin-debug \ upload_file.php中分配10368字節)
原始圖像的大小爲:5,136 KB運行PHP。
但如果我嘗試其他的圖像大小爲:2,752 KB它工作..
可有人請幫我這。 Zeeshan