Merging Three or More Images -- PHP
Posted
by
bballer13sn
on Stack Overflow
See other posts from Stack Overflow
or by bballer13sn
Published on 2011-11-17T17:45:03Z
Indexed on
2011/11/17
17:51 UTC
Read the original article
Hit count: 143
php
Before I ask my question, I'd like to thank you all in advance for helping me with this. So here's the question:
So, for my website, I've been trying to make it so people's characters (which are currently composed of several pictures that are moved by CSS) are merged into one image as to make my life easier. The chunk of code that currently doesn't work is as follows:
$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...
This is the error PHP is giving me:
Warning: imagepng() [function.imagepng]: Unable to open 'Images/' for writing: Is a directory in PathToParentFolderOfFollowingFile/testFile.php on line 139
What exactly does this error mean and how can it be fixed?
NOTE: $charRow
is not the problem. The query to get that is just not being displayed to all of you.
© Stack Overflow or respective owner