Jump to content

Showing an image


cheechm

Recommended Posts

Hi,

I am trying to show an image using this script:

 

      function CopyImageFileGD($name,$ext,$newwidth,$newheight) {

          if($ext == "jpg"){

               $new_img = imagecreatefromjpeg("images_files/$name");

           }elseif($ext == "png"){

               $new_img = imagecreatefrompng("images_files/$name");

           }elseif($ext == "gif"){

               $new_img = imagecreatefromgif("images_files/$name");

           }	   



           list($width, $height) = getimagesize("images_files/$name");
	  

           if (function_exists(imagecreatetruecolor)){
           $resized_img = imagecreatetruecolor($newwidth,$newheight);
           }

           imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
           ImageJpeg ($resized_img);
           ImageDestroy ($resized_img);
           ImageDestroy ($new_img);
		}

        $Ext = getFileExtension($_GET[File]);			



	if(!empty($_GET[File]) && !empty($_GET[w]) && !empty($_GET[h]))
	{

	include"config.php";		
	if(!empty($_GET[Large]))
	{
	$q1 = "update `images` set `Viewed` = Viewed+1 where `Image` = '$_GET[File]'";
	mysql_query($q1) or die(mysql_error());		

	}
	header('Content-Type: image/jpeg');
	$Image = CopyImageFileGD($_GET[File],$Ext,$_GET[w],$_GET[h]);
	}

 

An example address is www.mydomain.com/photos/image.php?File=1178320821.jpg&w=150&h=112.5

 

image.php is in the same directory as images_files.

The thing is, that the image doesn't show.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/50125-showing-an-image/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.