【发布时间】:2009-12-23 03:52:31
【问题描述】:
根据给我的任务,我正在尝试查看以下两个 php 函数对图像文件的影响 1.imagecreatefromjpeg 2.图片jpeg
我使用 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();
}
?>
但是当我这样做时,我得到以下输出:
致命错误:第 3 行 C:\Users\zee\Documents\Flex Builder 3\CLOUD\bin-debug\upload_file.php 中允许的内存大小为 33554432 字节已用尽(尝试分配 10368 字节)
原始图像大小为:5,136 KB 运行 php.ini 后出现上述错误。
但如果我尝试其他大小为 2,752 KB 的图像,它可以工作..
有人可以帮我解决这个问题吗? 泽山
【问题讨论】:
标签: php