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
| <?php
$rep = opendir( "images" );
$images = array( );
while( $fnom = readdir( $rep ) )
{
if ( preg_match( "/[.]JPG$/", $fnom ) )
$images []= $fnom;
}
closedir( $rep );
foreach( $images as $fnom )
{
$im = imagecreatefromjpeg( "images/$fnom" );
$ox = imagesx( $im );$oy = imagesy( $im );
$nx = 100;
$ny = floor( $oy * ( 100 / $ox ) );
$nm = imagecreatetruecolor( $nx, $ny );
imagecopyresized( $nm, $im, 0, 0, 0, 0, $nx, $ny, $ox, $oy );
print "Création de la vignette de $fnom\n";
imagejpeg( $nm, "vignettes/$fnom" );
}
print "Création du fichier index.html\n";
ob_start( );
?>
<html>
<head><title>Vignettes</title></head>
<body>
<table cellspacing="0" cellpadding="2" width="500">
<tr>
<?php
$index = 0;
foreach( $images as $fnom ) {
?>
<td valign="middle" align="center">
<a href="images/<?php echo( $fnom ); ?>"><img src="vignettes/<?php echo($fnom ); ?>" border="0" /></a>
</td>
<?php
$index += 1;
if ( $index % 5 == 0 ) { echo( "</tr><tr>" ); }
}
?>
</tr>
</table>
</body>
</html>
<?php
$html = ob_get_clean( );
$fh = fopen( "index.html", "w" );
fwrite( $fh, $html );
fclose( $fh );
?> |
Partager