1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
<?php
function list_dir($argv)
{
$tableau2 = array();
foreach($argv as $value)
{
if(is_dir($value))
{
if ($dir = opendir($value))
{
while($file = readdir($dir))
{
$ignoreList = ['.', '..'];
//echo $file . PHP_EOL;
if($file != in_array($file, $ignoreList)
&& fnmatch("*.png", $file)
|| fnmatch("*.jpeg", $file)
|| fnmatch("*.jpg", $file)
|| fnmatch("*.tiff", $file)
|| fnmatch("*gif", $file))
{
$tableau2[] = $file;
}
}
}
}
}
closedir($dir);
$largeur_total = 0;
$hauteurmax = 0;
print_r($tableau2);
foreach ($tableau2 as $entry)
{
if(fnmatch("*.jpeg", $entry) || fnmatch("*.jpg", $entry))
{
$source = imagecreatefromjpeg($entry); // Source tableau
$dimensionsx = imagesx($source);
$dimensionsy = imagesy($source);
$largeur_total += ($dimensionsx);
if ($dimensionsy > $hauteurmax) {
$hauteurmax = $dimensionsy;
}
echo $largeur_total;
$pos = 0;
$padding = 0;
$image = imagecreatetruecolor($largeur_total, $hauteurmax); //
imagesavealpha($image, true);
$blanc = imagecolorallocate($image, 255, 255, 255);
$transparent = imagecolorallocatealpha($image, 0, 0, 0, 127); // definit l'arriere plan transparent
imagefill($image, 0, 0, $transparent);
// On met les photos dans l'image de destination (l'image de base)
imagecopymerge($image, $source, $pos, 0, 0, 0, $dimensionsx, $dimensionsy, 100);
$pos += ($padding + $hauteurmax);
imagepng($image, "essai.png"); //enregistre l'image modifiée
echo $pos . PHP_EOL;
}
}
var_dump(list_dir($argv));
}
list_dir($argv); |
Partager