PHP Auto image resizing Script

PHP Auto image resizing Script

Today, We want to share with you PHP Auto image resizing Script.In this post we will show you Simple PHP image upload, resize and rename script?, hear for PHP Image Compression, Resize & Optimization we will give you demo and example for implement.In this post, we will learn about php image resize and save to folder with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Snippet Contents

PHP Auto image resizing Script

There are the Following The simple About PHP Auto image resizing Script Full Information With Example and source code.

As I will cover this Post with live Working example to develop Copy and resize part of an image, so the resize image php before upload for this example is following below.

PHP Code Source

This PHP script Auto resize an Image into two 60px and 25px. Take a look at $newwidth you have to change your dynamic size values.


 define ("MAX_SIZE","400");

        $image =$_FILES["file"]["name"];
		 $getCatalogFile = $_FILES['file']['file_temp_name'];
		  if ($image) 
			  $filename = stripslashes($_FILES['file']['name']);
					$file_ext = fetchFileExtension($filename);
			  $file_ext = strtolower($file_ext);
			 if (($file_ext != "jpg") && ($file_ext != "jpeg") 

			&& ($file_ext != "png") && ($file_ext != "gif")) 
				echo 'Sorry, Unknown Image file_ext ';
			if ($size > MAX_SIZE*1024)
				 echo "sorry, You have exceeded the size limit";
			if($file_ext=="jpg" || $file_ext=="jpeg" )
				$getCatalogFile = $_FILES['file']['file_temp_name'];
				$source = imagecreatefromjpeg($getCatalogFile);
			else if($file_ext=="png")
				$getCatalogFile = $_FILES['file']['file_temp_name'];
				$source = imagecreatefrompng($getCatalogFile);
				$source = imagecreatefromgif($getCatalogFile);







			$filename = "images/". $_FILES['file']['name'];
			$filename1 = "images/small". $_FILES['file']['name'];



 if(isset($_POST['Submit']) && !$get_errors) 
   // mysql_query("update SQL statement ");
  echo "Your Latest Image Uploaded Successfully!";


Global Methods get the Extention PHP funtion

simple PHP Finds file extensions.

function fetchFileExtension($str) {

         $i = strrpos($str,".");
         if (!$i) { return ""; } 

         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Auto image resizing Script.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP Image Resize Tutorials
  2.   VueJs count array of total items Example
  3.   PHP Image Resize, Crop, Thumbnail, Watermark
  4.   PHP Crop/Resize Image Function using GD Library
  5.   Send HTML Form Data as JSON via Ajax
  6.   PHP Variable Scope Global Static & Local
  7.   PHP Curl Fetch getAllheaders HTTP Request
  8.   Image Resize Crop Thumbnail Watermark PHP Script
  9.   PHP Automatic Flexify image resizing
  10.   Strong Random Password Generator Using VueJS