Jump to content

Image Resize Query?


Solarpitch

Recommended Posts

Hey,

 

I am currently using the below script to try and resize and image if its too large but it doesn't seem to be uploading correctly, rather it just uploads the full size image. Is this the correct way to implement this script syntax wise? I think I've gone wrong somewhere!

 

 


$image1 = $_FILES['image1']['tmp_name'];

if($_FILES['image1']['tmp_name'] != ""){

list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']);

move_uploaded_file($_FILES['image1']['tmp_name'], $image1file);

if(($width > $height) && ($width > 800))
			{
				$height = (($height/$width) * 800);
				$width = 800;
				$resize = "true";
			}
			else if (($height > $width) && ($height > 800)) 
			{
				$width = (($width/$height) * 800);
				$height = 800;
				$resize = "true";
			}

if ($resize == "true")
			{
				$new_w    =    760;
   			   	         $new_h    =    500;

				$resize = imagecreatetruecolor($width, $height);
				$im = imagecreatefromjpeg($image1);

				imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $new_w, $new_h);
				imagejpeg($resize, $new_source, $quality); 

				$newsize1 = $im;
				$new1 = "true";

			}
                            }


 

 

Link to comment
https://forums.phpfreaks.com/topic/76899-image-resize-query/
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.