free utilise bien la librairie GD, tiens c’est cadeau mais pas vraiment très propre comme code.
[code]<?php
$array_jpg=NULL;
$dirpath="./";
function jpg2tab($array_jpg, $path)
{
if (!is_object($handle = dir($path)))
{
return false;
}
while($file = $handle -> read())
{
if($file != “.” && $file != “…”){
if(preg_match("/.jpg/i", $file)){
$array_jpg[] = $file;
}
}
}
return $array_jpg;
}
function tab2png($tab, $path)
{
chdir($path);
foreach($tab as $file)
{
$out = preg_replace("/.jpg/i", “.png”, $file);
if (!file_exists($out)){
$attr = getimagesize($file);
$src = imagecreatefromjpeg($file);
$dest = imagecreatetruecolor(200,150);
imagecopyresampled($dest,$src,0,0,0,0,200,150,$attr[0],$attr[1]);
imagepng($dest,$out, 2);
}
}
}
function show_png($tab, $path)
{
foreach($tab as $file)
{
$out = eregi_replace(".jpg", “”, $file);
echo “<a href=”$path$out.jpg"><img src="$path$out.png" border=“0”>";
}
}
?>