Read the bottom first, where the most current information is. Most of this is old information (though you might need it).
I'm starting on making a PHP function that morphs/deforms an image you give it. I need to make a black background for starting, so this is what I have so far: (not anymore)
function morph($img) {
list($width, $height) = getimagesize($img);
//$width = $size[0];
//$height = $size[1];
$tempImg = imagecreatetruecolor($width, $height);
//Create the image background
imagefilledrectangle($tempImg, 0, 0, $width, $height, imagecolorallocate($tempImg, 0, 0, 0));
return $tempImg;
}
But all it gives me is a broken image, at least from the browser's perspective. What could be wrong? Thanks in advance.
EDIT: An alternative to fixing this, which a lot of people are having trouble with, would be to simply make a method that creates a true color image the same size as an imag from an argument that is filled with black. I'll do my best to do this, but it'd be great if you could help too.
This is my current attempt:
function morph($img) {
list($width, $height) = getimagesize($img);
//$width = $size[0];
//$height = $size[1];
$tempImg = imagecreatetruecolor($width, $height);
//Create the image background
imagefilledrectangle($tempImg, 0, 0, $width, $height, imagecolorallocate($tempImg, 0, 0, 0));
return $tempImg;
}
Same result.
EDIT 2: I have found the source of the problem! After snooping around the result, I found that the dimensions imagecreatetruecolor() was receiving were invalid. I'm doing something wrong in getimagesize() and the array I'm getting. I need to figure out what.
EDIT 3: The problem is in getimagesize(). It says no such file or directory at at line 13 (the line with getimagesize). What's wrong? This was the problem all along.