I was trying to form an image from multiple images that fall under a certain pattern. but in the end I only get a gray box and the date, despite the fact that the array of found images is not empty.
$name = $_GET['gn'];
$dest = 'images/sprites/';
$images = array();
$dir = getcwd() . '/images/thumb';
$dir_b = $dir.'/real-size';
$pattern = $dir_b.'/{'.$name.'}*.jpg';
$images = glob($pattern,GLOB_BRACE);
list($step_w,$step_h) = getimagesize($images[0]);
$fi = imagecreate($step_w*count($images), $step_h);
$bg = imagecolorallocate($fi, 200, 200, 200);
imagefill($fi, 0, 0, $bg);
imagealphablending($fi, false);
imagesavealpha($fi, true);
ksort($images);
foreach($images as $k => $i){
$pi = imagecreatefromjpeg($i);
imagecopy($fi,$pi,$k*$step_w,0,0,$step_w,$step_h);
imagedestroy($pi);
}
$textcolor = imagecolorallocate($fi, 0, 0, 255);
imagestring($fi, 5, 0, 0, date('H:i:s'), $textcolor);
imagepng($fi, $dest.$name.'.png');
imagedestroy($fi);
Where is the mistake and what can i do to fix it?
After some comments: I can safely say that the cycle passes all four times, each time a variable $pi
is taking valid value