imagecreatefromjpeg

Godlike_Killer

Power Member
Tenho aqui uma situação... Fiz um sistema de registo em PHP que estava a funcionar correctamente, mas agora surgiu um problema não se porquê... Penso que seja por causa do upload do avatar dos utilizadores...
O erro é este: 1Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\programas\easyphp1-8\www\site_projecto_act\site\inserir.php on line 5
Achei estranho, porque a função está definida, como podem ver no código que fiz e coloco a seguir:

Código:
<?php
@session_start();
function thumbnail($image, $thumbpath, $qualidade, $max_width, $max_height)
{ 
        $src_img = imagecreatefromjpeg($image); 
        $width = imagesx($src_img);
        $height = imagesy($src_img);
        if ($height>$width && $height>=$max_height)
        {
            $height_image=$max_height;
            $width_image=intval(($width*$max_height)/$height);
        }
        else
        {
            if ($width>$height && $width>=$max_width)
            {
                $width_image=$max_width;
                $height_image=intval(($height*$max_width)/$width);
            }
            else
            {
                $width_image=$width;
                $height_image=$height;
            }    
        }

        $dst_img = imagecreatetruecolor($width_image,$height_image); 
        imagecopyresized($dst_img,$src_img,0,0,0,0,$width_image,$height_image,$width,$height); 
        imagejpeg($dst_img, $thumbpath,$qualidade);
        
}
$username= "";
$password= "";
$tipo = 1;
$primeiro_nome = "";
$ultimo_nome = "";
$data = "";
$pergunta_secreta = "";
$resposta = "";

$mensagem_erro="";
$mensagem_erro2="";
if(isset($_POST['validar_form'])) {
    $username = $_POST['user'];
    $password = $_POST['pass'];
    $primeiro_nome = $_POST['primeiro_nome'];
    $ultimo_nome = $_POST['ultimo_nome'];
    $data = $_POST['data_nascimento'];
    $foto = $_FILES['foto']['name'];
    move_uploaded_file($_FILES['foto']['tmp_name'], "fotos/". $foto);
    
     thumbnail("fotos/". $foto,"fotos/"."thumb_".$foto,50,200,200);
     
    $pergunta_secreta = $_POST['pergunta_secreta'];
    $resposta = $_POST['resposta'];


    if(!(empty($username) || empty($password)|| empty($primeiro_nome)|| empty($ultimo_nome)|| empty($data))|| empty($pergunta_secreta) || empty($resposta)){
        include "include/conexao.php";

        $query = "SELECT * FROM utilizadores WHERE username = '$username'";
        $res = mysql_query($query);
                
        if($row = mysql_fetch_assoc($res)) { 
            $mensagem_erro2="Este utilizador já existe";
        }        
        else {
        
    
        // CONSULTA
        $query = "INSERT INTO utilizadores (username, password, tipo, foto, primeiro_nome, ultimo_nome, data_nascimento) VALUES ('$username','$password', '$tipo', '$foto', '$primeiro_nome', '$ultimo_nome', '$data')";
    
        // EXECUTAR A INSTRUÇÃO
        $resultado = mysql_query($query);
        
        header("location: index.php");
        exit();
        }
    }
    else $mensagem_erro = "Tem de preencher todos os campos";
}

Se alguém souber como resolver este problema, diga-me sff.
Agradeço desde já toda a ajuda que me possam disponiblizar :)
 
Penso que a livraria já esteja activa...
Na página diz para não comentar a linha respectiva, no php.ini, mas esta já não estava comentada. Para o caso de estar a fazer alguma asneira, deixo aqui as instruções que segui e a linha do php.ini referida:

Código:
[B]Windows [/B]

 The php_gd2.dll is included in a standard PHP installation for Windows, it's not enabled by default. You have to turn it on, the user may simply uncomment the line "extension=php_gd2.dll" in php.ini and restart the PHP extension. 
Change: 
 #extension=php_gd2.dll
To: 
 extension=php_gd2.dll
You may also have to correct the extension directory setting from: 
 extension_dir = "./"

Or:

extension_dir = "./extensions"

[B]NOTE:[/B] SUBSTITUTE THE ACTUAL PHP INSTALLATION DIRECTORY ON [B]*YOUR*[/B] COMPUTER.
To (FOR WINDOWS): 
 extension_dir = "c:/php/extensions" 

extension_dir = "./extensions"
[B]NOTE:[/B] SUBSTITUTE THE ACTUAL PHP INSTALLATION DIRECTORY ON [B]*YOUR*[/B] COMPUTER.
To (FOR WINDOWS): 
 extension_dir = "c:/php/extensions"
Thanks to Benoit Blais for this last point. Thanks also to Alan MacDougall and Perculator.
Código:
;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_crack.dll
;extension=php_curl.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
[COLOR=Red][B]extension=php_gd2.dll[/B][/COLOR]


Já não tem o # atrás, ou fui eu que fiz alguma coisa mal ou o erro deve-se a outros motivos :lol:
 
Back
Topo