php images_files glob tmp png images array foreach images_files as img

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?php
$images_files = glob("/tmp/i*.png");
$images = array();
foreach ($images_files as $img) {
if (!($i = @imagecreatefrompng($img)))
$i = imagecreatefromjpeg($img);
$images[] = $i;
}
$out_img = array_shift($images);
imagealphablending($out_img, true);
imagesavealpha($out_img, true);
foreach ($images as $img) {
imagecopy($out_img, $img, 0, 0, 0, 0, imagesx($img), imagesy($img));
}
imagepng($out_img, "/var/www/000-default/xuj.png");