Hey people,

im not sure where im going wrong with this script but could someone please point out any obvious mistakes because I just don't get why its not working :S

$Eimage = $HTTP_POST_FILES['Thumbnail']['tmp_name'];
							  $Emax_width = 800;
							  $Emax_height = 600;

$Esize = GetImageSize($Eimage);

$Ewidth = $Esize[0];
$Eheight = $Esize[1];

$Ex_ratio = $Emax_width / $Ewidth;
$Ey_ratio = $Emax_height / $Eheight;

if ( ($Ewidth <= $Emax_width) && ($Eheight <= $Emax_height) ) {
								$Etn_width = $Ewidth;
								$Etn_height = $Eheight;
 }
else if (($Ex_ratio * $Eheight) < $Emax_height) {
								$Etn_height = ceil($Ex_ratio * $Eheight);
								$Etn_width = $Emax_width;
}
 else {
								$Etn_width = ceil($Ey_ratio * $Ewidth);
								$Etn_height = $Emax_height;
 }

$Esrc = gdImageCreateFromJpeg("$Eimage");
$Edst = gdImageCreateTrueColor($Etn_width,$Etn_height);
							  gdImageCopyResized($Edst, $Esrc, 0, 0, 0, 0,
								  $Etn_width,$Etn_height,$Ewidth,$Eheight);

						  gdImageJpeg($Edst, $Eimage, -1);
						  gdImageDestroy($Esrc);
						  gdImageDestroy($Edst);

thats the code i use for resizing the image which is uploaded using a simple upload form.

i get the error:
Fatal error: Call to undefined function: gdimagecreatefromjpeg()

I dont get why its saying its undefined when is says:
gdImageCreateFromJpeg("$Eimage");

Thanks for any help,

    Try
    imagecreatefromjpeg("$Eimage");

      That is because there is not a

      Fatal error: Call to undefined function: gdimagecreatefromjpeg()

      change it to'

      $Esrc = ImageCreateFromJpeg("$Eimage");
      $Edst = ImageCreateTrueColor($Etn_width,$Etn_height);
                                    ImageCopyResized($Edst, $Esrc, 0, 0, 0, 0,
                                        $Etn_width,$Etn_height,$Ewidth,$Eheight);
      
                                ImageJpeg($Edst, $Eimage, -1);
                                ImageDestroy($Esrc);
                                ImageDestroy($Edst);

      and see what you get.

        still get same error, think i originaly had it like that without the gd's but then after a vist to the gd site i got confused and thought id try it with them.

        could the server be blocking something?

        thanks for the reply.

          if this error happens that means no GD support has been installed. You'll have to deal with your server if you want it working

            ok, have contacted server people, hopefully they will be able to solve it, thanks for your input people!

              Write a Reply...