Gerando imagens em miniatura
Iae imasters, então eu to tentando gerar imagens em miniaturas com PHP+HTML o que acontece é que neste código a ideia é exibir a IMAGEM e o TÍTULO, no entanto só esta aparecendo o Título.Já criei os dois diretorios pics e thumbs. Meu objetivo é fazer um mosaico de noticias não sei bem se desta forma(script), é o melhor caminho.
Espero que me deem uma luz.
Valeu pessoal
<?php
$dir = opendir( "pics" );
$pics = array( );
while( $fname = readdir( $dir ) )
{
if ( preg_match("/[.]jpg$/", $fname ) ) $pics []= $fname;
}
closedir( $dir );
foreach( $pics as $fname)
{
$im = imagecreatefromjpeg( "pics/$fname" );
$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 "Creating thumbs for $fname\n";
imagejpeg( $nm, "thumbs/$fname" );
}
print "Creating index.html\n";
ob_start( );
?>
<html>
<head>
<title>Thumbmails</title>
</head>
<body>
<table cellspacing="0" cellspading="2" width="500">
<tr>
<?php
$index = 0;
foreach ($pics as $fname) {
?>
<td valing="middle" align="center">
<a href="pics/<?php echo( $fname ); ?>"><img src="thumbs/<?php echo ( $fname );
?>" 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 );
?>Discussão (1)
Carregando comentários...