GD imagecopyresampled() problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stijn Goris

    GD imagecopyresampled() problem

    hi all,

    I 'm trying to resize an image if it is to big. After the user uploads (with
    move_uploaded_f ile()) an image, it is checked for its resolution. If the
    image is to big it will be resized with imagecopyresamp le() .

    For some reason this doesn't seem to work. i have some questions... does the
    imagecopyresamp le() function need an image that is stored already on the
    server or does it need the image that is transmitted by the user...

    I have posted the code. Is someone can help me out...

    kind regards
    Stijn

    if ($_actie == "upload")
    {
    $type = $_FILES['imagefile']['type'];
    // chekc the type of image...

    $size = getimagesize($_ FILES['imagefile']['tmp_name']);


    if(!empty($_FIL ES["imagefile"]))
    {
    $uploaddir ='Leiding/fotos/';
    $_FILES["imagefile"]["name"]['upload_tmp_dir '] = NULL;
    $_FILES["imagefile"]["name"] = $_SESSION['IDg'].$ext;

    if (move_uploaded_ file($_FILES["imagefile"]["tmp_name"], $uploaddir .
    $_FILES["imagefile"]["name"]))
    {
    $fileName = $_FILES["imagefile"]["name"];
    $IDTemp = $_SESSION['IDgebruiker'];
    $result = mysql_query("UP DATE tblpersoon SET foto='$fileName ' WHERE
    ID='$IDTemp'") or die("Kan geen verbinding maken - Foto toevoegen<br>" .
    mysql_error());
    if ($size[0] > 380)
    {
    $srcImg = imagecreatefrom jpeg("$uploaddi r$fileName");
    $factor = 380/$size[0];
    $dstSizeW = $size[0]*$factor;
    $dstSizeH = $size[1]*$factor;

    $dstImg = imagecreate(dst SizeW, dstSizeH) or die ("Cannot Initialize
    new GD image stream");;
    imagecopyresamp led ($dstImg, $srcImg, 0, 0, 0, 0,$dstSizeW,
    $dstSizeH, $size[0], $size[1]);

    imagedestroy($s rcImg);
    imagedestroy($d stImg);
    }
    else
    {

    }
    }
    else
    {

    }

    }
    }
    else
    {

    }

    }


Working...