Jump to content

Image is not resizing?


shadiadiph

Recommended Posts

Sorry bit rusty but been trying this for hours I upload an image no errors are showing i upload a jpg file and it saves to the server fine but its saving the original size not the new resized image size any ideas??

 

 

if (isset ($_FILES['file'])) {

		$tmp_name = $_FILES["file"]["tmp_name"];
                  $file_type = $_FILES["file"]["type"];
		$fileatt_name = $_FILES["file"]["name"];

if ($file_type=="image/pjpeg" OR $file_type=="image/jpeg" OR $file_type=="image/jpg")
{ 
$src = imagecreatefromjpeg($tmp_name);
} // END if ($file_type=="image/pjpeg" OR $file_type=="image/jpeg" OR $file_type=="image/jpg")

if ($file_type=="image/png" OR $file_type=="image/x-png")
{ 
$src = imagecreatefrompng($tmp_name);
} // END if ($file_type=="image/png" OR $file_type=="image/x-png")

if ($file_type=="image/gif")
{ 
$src = imagecreatefromgif($tmp_name);
} // END if ($file_type=="image/gif")

list($width,$height)=getimagesize($tmp_name);
$width = $width;
$height = $height;
$newwidth = "200";
$newheight = "200";
$ratio='';

if($width==$height)
{
$newwidth = "200";
$newheight = "200";
}

if($width>$height)
{
$ratio=($height/$width);
$newwidth = "200";
$newheight = ($newwidth*$ratio);
}

if($width<$height)
{
$ratio=($width/$height);
$newheight = "200";
$newwidth = ($newheight*$ratio);
}

$tmp = imagecreatetruecolor($newwidth, $newheight); 
$new=imagecopyresampled($tmp, $src,0,0,0,0,$newwidth,$newheight,$width,$height); 
$filename = "./yxy/". $fileattt_name;
imagejpeg($tmp,$filename,100);    
imagedestroy($tmp);

}

Link to comment
https://forums.phpfreaks.com/topic/233824-image-is-not-resizing/
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.