This is my code:
$data = json_decode($_REQUEST['data'], true);
for ($x = 0; $x <= count($data); $x++) {
$img = imagecreate($data[$x][0],$data[$x][1]);
$img2 = imagecreatefromjpeg("apple.jpg");
$background_color = imagecolorallocate($img, 0, 0, 0);
imagecopymerge($img, $img2, $data[$x][2],$data[$x][3],0,0,$data[$x][4],$data[$x][4],100);
header("Content-Type: image/png");
imagepng($img, "icon".$x."png");
imagedestroy($img);
imagedestroy($img2);
}
$data gives back the correct data so no problems there, but the outcome are black squares with blank squares(instead of the image) in them. Does someone know how I can make the smaller square the actual image I'm trying to use?