Ajuda thumb.php

21 views
Skip to first unread message

Mohandas

unread,
Mar 20, 2012, 8:30:24 PM3/20/12
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;

?>

rogerio Lamarques

unread,
Mar 21, 2012, 9:21:02 AM3/21/12
to lista...@googlegroups.com
o parâmetro $ HTTP_GET_VARS  não se usar mais tenta com $_GET

Rogerio Martins Lamarques
Sócio/Gerente
www.nanith.com.br
nan...@nanith.com.br



--
You received this message because you are subscribed to the Google
Groups "PHPRS" group.
To post to this group, send email to lista...@googlegroups.com
To unsubscribe from this group, send email to
lista-phprs...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/lista-phprs?hl=en

bruno .

unread,
Mar 21, 2012, 9:41:45 AM3/21/12
to lista...@googlegroups.com
Galera, para enviar imagens, tem q configuarar o encitype do formulario
No php arquivos de data vem como $_FILES

não sao get nem post.


Date: Wed, 21 Mar 2012 10:21:02 -0300
Subject: Re: [PHPRS] Ajuda thumb.php
From: rogerio....@gmail.com
To: lista...@googlegroups.com

Felipe Fürst

unread,
Mar 21, 2012, 2:30:36 PM3/21/12
to lista...@googlegroups.com
Experimenta tirar os @ das funções tb ... deve ter algum erro que você não está enxergando por estar suprimindo ...
--
---------------------------------------
Felipe Furst

Mohandas

unread,
Mar 22, 2012, 9:01:53 PM3/22/12
to PHPRS
Fiz as mudanças mas continua com problemas ainda amigo ja verifiquei a
biblioteca dg no php.ini ela esta ativada

On 21 mar, 10:21, rogerio Lamarques <rogerio.lamarq...@gmail.com>
wrote:
> o parâmetro $ HTTP_GET_VARS  não se usar mais tenta com $_GET
>
> Rogerio Martins Lamarques
> Sócio/Gerentewww.nanith.com.br
> nan...@nanith.com.br
>

Gilton Guma

unread,
Apr 2, 2012, 7:43:10 AM4/2/12
to lista...@googlegroups.com
Utilize esta classe, vai facilitar as coisas:
http://www.daviferreira.com/posts/canvas-nova-classe-para-manipulacao-e-redimensionamento-de-imagens-com-php

*Verifique também as permissões de pastas (deve estar "777" para upload), se quiser uma maior segurança e se seu host permitir utilize "chmod()" (http://php.net/manual/pt_BR/function.chmod.php).

É isso, espero ter ajudado! ;)
Reply all
Reply to author
Forward
0 new messages