我的imagecreatefrompng功能有问题,它之前在共享主机上工作但是当我将它迁移到安装在ubuntu上的apache2时,php5没有加载内部服务器错误500
PHP版本5.5.9 Apache 2.4 在Ubuntu上主持
<?php
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefrompng('icon.png');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 0, 0, 0);
// Set Path to Font File
$font_path = 'OpenSans-Bold.ttf';
// Set Text to Be Printed On Image
$text = "1";
// Print Text On Image
imagettftext($jpg_image, 10, 0, 18, 20, $white, $font_path, $text);
imagesavealpha($jpg_image, true);
// Send Image to Browser
imagepng($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
?>
我试过
1-多次重启Web Server Apache2 2-更改映像文件以验证文件是否已损坏 3-在php5中安装与图像相关的少量组件,如php5-imagick或php5-exactimage 4-在apache2.conf中将EnableSendFile设置为Off 5-尝试将代码放入try catch但无法捕获异常
我无法解决此问题?我是否需要安装任何php组件或升级任何内容?
谢谢,
此致
答案 0 :(得分:0)
我明白了,实际上我没有为PHP5安装GD组件。要将此库用于PNG和JPEG文件,必须安装GD组件。