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.
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.
MAX_SIZE*1024) { echo "sorry, You have exceeded the size limit"; $get_errors=1; } 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); } else { $source = imagecreatefromgif($getCatalogFile); } list($width,$height)=getimagesize($getCatalogFile); $newwidth=60; $newheight=($height/$width)*$newwidth; $file_temp=imagecreatetruecolor($newwidth,$newheight); $img_width1=25; $img_height1=($height/$width)*$img_width1; $img_temp=imagecreatetruecolor($img_width1,$img_height1); imagecopyresampled($file_temp,$source,0,0,0,0,$newwidth,$newheight, $width,$height); imagecopyresampled($img_temp,$source,0,0,0,0,$img_width1,$img_height1, $width,$height); $filename = "images/". $_FILES['file']['name']; $filename1 = "images/small". $_FILES['file']['name']; imagejpeg($file_temp,$filename,100); imagejpeg($img_temp,$filename1,100); imagedestroy($source); imagedestroy($file_temp); imagedestroy($img_temp); } } } 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 :
Summary
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 Pakainfo.com 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.