Mohandas
unread,Mar 20, 2012, 8:30:24 PM3/20/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to lista...@googlegroups.com
Pessoal to precisando de uma ajuda ai! to tentando gerar as miniaturas mas nao da certo fica dando erro:
<?php
if ( isset( $_GET["image"] ) ) {
$image = $_GET["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 = "150";
}
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, "Faltando Imagem", $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 );
// Tamanho padrao caso a imagem seja menor
$nlargura = $largura;
$naltura = $altura;
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, 90 );
exit;
?>