<?php
/*
* Examples / Exemplos:
* <img src="createthumb.php?image=filename.jpg">
* <img src="createthumb.php?image=filename.jpg&max=200">
*/
if ( isset( $HTTP_GET_VARS["image"] ) ) {
$image = $HTTP_GET_VARS["image"];
} else {
echo "Parâmetro \"image\" faltando.<BR>";
echo "Parameter \"image\" missing.";
exit;
}
if ( isset( $HTTP_GET_VARS["max"] ) ) {
$max = $HTTP_GET_VARS["max"];
} else {
$max = "100";
}
if ( !function_exists( "imagecreatefromstring" ) ) {
header( "location: $image" );
exit;
}
$im = @imagecreatefromstring( @fread( @fopen( $image, "r" ), @filesize( $image ) ) );
if ( !strlen( $im ) ) {
$im = imagecreate ( $max, $max );
$bgc = imagecolorallocate ( $im, 255, 255, 255 );
$tc = imagecolorallocate ( $im, 0, 0, 0 );
imagefilledrectangle ( $im, 0, 0, 150, 30, $bgc );
imagestring ( $im, 2, 3 , 15, "Erro ao carregar", $tc );
imagestring ( $im, 2, 18, 30, "miniatura.", $tc );
imagestring ( $im, 2, 10, 55, "Error on load", $tc );
imagestring ( $im, 2, 18, 70, "thumbnail.", $tc );
header( "Content-type: " . image_type_to_mime_type( IMAGETYPE_PNG ) );
echo imagepng( $im );
exit;
}
$largura = imagesx( $im );
$altura = imagesy( $im );
if ( $largura >= $altura ) {
if ( $largura > $max ) {
$naltura = ( $max / $largura ) * $altura;
$nlargura = ( $max / $largura ) * $largura;
}
} else {
if ( $altura > $max ) {
$nlargura = ( $max / $altura ) * $largura;
$naltura = ( $max / $altura ) * $altura;
}
}
if ( function_exists( 'imagecopyresampled' ) ) {
if ( function_exists( 'imageCreateTrueColor' ) ) {
$ni = imageCreateTrueColor( $nlargura, $naltura );
} else {
$ni = imagecreate( $nlargura, $naltura );
}
if ( !@imagecopyresampled( $ni, $im, 0, 0, 0, 0, $nlargura, $naltura, $largura, $altura ) ) {
imagecopyresized( $ni, $im, 0, 0, 0, 0, $nlargura, $naltura, $largura, $altura );
}
} else {
$ni = imagecreate( $nlargura, $naltura );
imagecopyresized( $ni, $im, 0, 0, 0, 0, $nlargura, $naltura, $largura, $altura );
}
header( "Content-type: " . image_type_to_mime_type( IMAGETYPE_JPEG ) );
echo imagejpeg( $ni, null, 70 );
exit;
?>
Miniatura De Gif Animado
Started By lifeofgames, 07/05/2005, 16:09
6 replies to this topic
#1
Posted 07/05/2005, 16:09
Tenho o seguinte codigo, ele gera tumbs de gif, e mexe corretamente, mas gostaria de capturar as imagens da pasta toda e gerar com esse script, me ajudem ae.
Aprendendo a Amar - O Encanto é aqui!
www.aprendendoaamar.com
www.aprendendoaamar.com
#2
Posted 07/05/2005, 19:17
Af a duvida é de gif animado ou de criar thunbs da pagina toda??
#3
Posted 07/05/2005, 19:46
Tenta assim. Não testei
<?
// pasta de onde o script vai carregar as imagens
$dir = "./nomedasuapasta";
// função que vai gerar thumb
function gerathumb($arquivoimg) {
/*
* Examples / Exemplos:
* <img src="createthumb.php?image=filename.jpg">
* <img src="createthumb.php?image=filename.jpg&max=200">
*/
if ( isset( $arquivoimg ) ) {
$image = $arquivoimg;
} else {
echo "Parâmetro \"image\" faltando.<BR>";
echo "Parameter \"image\" missing.";
exit;
}
if ( isset( $arquivoimg["max"] ) ) {
$max = $arquivoimg["max"];
} else {
$max = "100";
}
if ( !function_exists( "imagecreatefromstring" ) ) {
header( "location: $image" );
exit;
}
$im = @imagecreatefromstring( @fread( @fopen( $image, "r" ), @filesize( $image ) ) );
if ( !strlen( $im ) ) {
$im = imagecreate ( $max, $max );
$bgc = imagecolorallocate ( $im, 255, 255, 255 );
$tc = imagecolorallocate ( $im, 0, 0, 0 );
imagefilledrectangle ( $im, 0, 0, 150, 30, $bgc );
imagestring ( $im, 2, 3 , 15, "Erro ao carregar", $tc );
imagestring ( $im, 2, 18, 30, "miniatura.", $tc );
imagestring ( $im, 2, 10, 55, "Error on load", $tc );
imagestring ( $im, 2, 18, 70, "thumbnail.", $tc );
header( "Content-type: " . image_type_to_mime_type( IMAGETYPE_PNG ) );
echo imagepng( $im );
exit;
}
$largura = imagesx( $im );
$altura = imagesy( $im );
if ( $largura >= $altura ) {
if ( $largura > $max ) {
$naltura = ( $max / $largura ) * $altura;
$nlargura = ( $max / $largura ) * $largura;
}
} else {
if ( $altura > $max ) {
$nlargura = ( $max / $altura ) * $largura;
$naltura = ( $max / $altura ) * $altura;
}
}
if ( function_exists( 'imagecopyresampled' ) ) {
if ( function_exists( 'imageCreateTrueColor' ) ) {
$ni = imageCreateTrueColor( $nlargura, $naltura );
} else {
$ni = imagecreate( $nlargura, $naltura );
}
if ( !@imagecopyresampled( $ni, $im, 0, 0, 0, 0, $nlargura, $naltura, $largura, $altura ) ) {
imagecopyresized( $ni, $im, 0, 0, 0, 0, $nlargura, $naltura, $largura, $altura );
}
} else {
$ni = imagecreate( $nlargura, $naltura );
imagecopyresized( $ni, $im, 0, 0, 0, 0, $nlargura, $naltura, $largura, $altura );
}
header( "Content-type: " . image_type_to_mime_type( IMAGETYPE_JPEG ) );
echo imagejpeg( $ni, null, 70 );
}
if (is_dir($dir)) {
if ($pasta = opendir($dir)) {
while (($arq_imagem = readdir($pasta)) !== false) {
if (!(($arq_gif == ".") || ($arq_gif == "..")))
gerathumb($arq_gif);
}
closedir($pasta);
}
}
exit;
?>
#4
Posted 07/05/2005, 20:13
olha cara, ao vc tratar o GIF pela gd ele perde a animaçao, ele pega o primeiro frame dele...
a versao 2.0.33 da GD tem suporte a criação de GIF animado, porem eu nao sei como usar, pois não ha documentação disso para o uso em php :-\
a versao 2.0.33 da GD tem suporte a criação de GIF animado, porem eu nao sei como usar, pois não ha documentação disso para o uso em php :-\
๑۩۞۩๑Let the Carnage Begin!!๑۩۞۩๑
#5
Posted 07/05/2005, 20:14
Tipo..
jinyam
Hawk
Ele nao funcionou
jinyam
Hawk
Ele nao funcionou
Edição feita por: lifeofgames, 08/05/2005, 01:13.
Aprendendo a Amar - O Encanto é aqui!
www.aprendendoaamar.com
www.aprendendoaamar.com
#6
Posted 07/05/2005, 20:48
poisé, como eu disse, depois de passar pela GD ele fica estatico, ele pega só o primeiro frame do gif
๑۩۞۩๑Let the Carnage Begin!!๑۩۞۩๑
#7
Posted 08/05/2005, 00:43
entendi, mas entao como eu faço pra fazer o que eu quero sem passar pra gb, basiado no primeiro codigo?
Aprendendo a Amar - O Encanto é aqui!
www.aprendendoaamar.com
www.aprendendoaamar.com
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)










