【发布时间】:2011-11-17 17:45:03
【问题描述】:
对于我的网站,我一直在尝试将人们的角色(目前由几张由 CSS 移动的图片组成)合并到一张图片中,以使我的生活更轻松。目前不起作用的代码块如下:
$template = $charRow['template'];
$gender = $charRow['gender'];
$shirt = $charRow['shirt'];
$pants = $charRow['pants'];
$hat = $charRow['hat'];
$templatePic = imagecreatefrompng("Templates/".$template);
if (!empty($shirt)) {
$shirtPic = imagecreatefrompng($shirt);
imagecopy($templatePic,$shirtPic,0,0,0,0,imagesx($templatePic),imagesy($templatePic));
}
if (!empty($pants)) {
$pantsPic = imagecreatefrompng($pants);
imagecopy($templatePic,$pantsPic,0,0,0,0,imagesx($templatePic),imagesy($templatePic));
}
if (!empty($hat)) {
$hatPic = imagecreatefrompng($hat);
imagecopy($templatePic,$hatPic,0,0,0,0,imagesx($templatePic),imagesy($templatePic));
}
imagePNG($templatePic, 'Images/'); //Problem line...
这是 PHP 给我的错误:
警告:imagepng() [function.imagepng]:无法打开“Images/”进行写入:是 PathToParentFolderOfFollowingFile/testFile.php 中第 139 行的目录
这个错误究竟是什么意思,如何解决?
注意:$charRow 不是问题所在。获取它的查询并没有显示给你们所有人。
另外...您如何使透明度起作用?我正在使用的所有文件都是具有透明度的 PNG 文件。
【问题讨论】:
-
想到两件事 - 您的 php 应用程序没有访问图像目录的权限,或者您没有正确的图像目录路径。
-
类似问题已回答here。
标签: php