Gd库给出了破碎的图像和覆盖wordpress主题


gd library gives broken image and overrides wordpress theme

我已经创建了一个新的模板,并添加了以下代码:

<?php
$stamp = imagecreatefrompng('images/haz.png');
$im = imagecreatefromjpeg('images/baz.jpg');
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

出于某种原因,这只是覆盖了我的整个主题,给了我一个破碎的图像https://i.stack.imgur.com/vheLR.png

我也尝试了一些我发现的其他代码,结果是一样的!我的主题消失了,我所看到的是一个破碎的图像。这使我相信我的服务器或GD库有问题。我用了phpinfo,这是我得到的

GD Support  enabled
GD Version  bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.3.11
GIF Read Support    enabled
GIF Create Support  enabled
JPG Support enabled
PNG Support enabled
WBMP Support    enabled
XPM Support enabled
XBM Support enabled

更让我烦恼的是,它不仅显示了一个破碎的图像,而且还覆盖了我的整个主题!我试着在谷歌上寻找一个解决方案,但似乎找不到一个!

这将是GD库遇到致命错误,并可能死亡/退出。