Loading.......
Loading...

Bulk image resize with PHP

Posted on 25th October, 2016
IMAGE RESIZE PHP PHOTO RESIZE PHP BULK IMAGE RESIZE RESIZE IMAGE IN PHP
One of the challenges that comes with maintaining a graphic-intensive website like social networking websites is finding a way to get high quality images throughout the site with as little effort as possible.

This tutorial teaches you how to design a system where you can easily resize or compress the image files that you have already uploaded to your server using PHP.

The major advantage of this system is that it allows you to resize and crop any image on your website without touching the actual image or writing any code.

The system is made up of two functions, one of the function scans and gets all the image files in a given directory and then passes those image files to the second function that does the resizing/compressing of the image files to your desired sizes.

The resizing/compressing of the image files are done depending on the aspect ratio of the file. The aspect ration of each file is calculated using the original width and height of the image file.

To resize or compress image files, you only need to open a file named configuration.php and set up the following:

CONFIGURATION FILE:

<?php
/* 
*This is the parent directory where all the files you want to resize, 
* including the sub-directories and the files in them are all located 
*/
define('UPLOADED_FILES_BASE_DIRECTORY', 'uploads');

/* 
* This is the width that all the resized files will have depending on their aspect ratio
*/
define('RESIZE_FILES_TO_width', '700');


/* 
* This is the height that all the resized files will have depending on their aspect ratio
*/
define('RESIZE_FILES_TO_height', '700');

// Aspect ration of each file is calculated using the width and height of the file
?>

Before a file can be resized or compressed, the system will first of all check the original size (width/height) of the image file comparing this size to your given size (width/height), if your given size are greater than the original size of the file, the system will compress the file using the original size of the file to maintain the aspect ratio of the file but if your given size are less than the original size of the file then the system will compress the file using your given size.

Features of the System:
1. Scans a given directory and sub-folders to get all the available image files in the directories
2. Resizes JPEGs, GIFs, and PNGs image files to new image dimensions, while still keeping the aspect ratio of the file
3. Intelligently sharpens for crisp photos at any size
4. Resize by exact width/height
5. Resize by width - exact width will be set, height will be adjusted according to aspect ratio - (landscape)
6. Resize by height - like Resize by Width, but the height will be set and width adjusted dynamically - (portrait)
7. Auto determine options 2 and 3. If you're looping through a folder with different size photos, let the script determine how to handle this
8. Resize, then crop, no image distortion

System Requirements:
PHP 5 or greater and compiled with GD Library
Post Comment
Press Enter to send
No comment yet.


Popular Tutorials Pagination System using Ajax, Jquery and PHPSend Friend Request, Accept or Decline Request using Ajax, Jquery and PHPContact Form with Captcha using Ajax, Jquery and PHPWhy Having a FREE website is bad ChoiceBulk image resize with PHPWeb Browser Notification System using JavaScriptIntroduction to php.ini FileTypes of PHP ErrorsProgram Execution Time Limit in PHPTo-do list using PHP and MySQLiMove File from One Folder to the other using PHPHow to change or convert MySQL to MySQLiHow to Upload Video Files using PHP and MySQLiConvert HTML to MS Word Document using PHPEight Reasons Why You Need A Business WebsiteLocal Web Development Server for Windows - XAMPPEasy Shopping Cart using HTML, CSS & JavaScriptComment System using PHP, Ajax and MySQLiAdd, Edit and Delete Record from Database using jQuery and PHPResponsive Contact Form with Captcha using Jquery and PHPUpdate or Delete Multiple Rows using PHPPassword Strength Checker using JqueryFacebook Style Auto Scroll Pagination using jQuery and PHPDomain Checker using Ajax, Jquery and PHPThe if else & elseif Statements in PHPPreview and upload multiple files using ajax and PHPFancy Multiple File Upload using Ajax, Jquery and PHPPagination System without Database using Ajax and PHPUnderstanding Cookies in JavaScript: Create, Read, Update and DeleteSecured Users Access Level System using PHP and MysqlSecure Forgot Password System Using Ajax, Jquery and PHPChat Script Similar to Facebook using Ajax and PHPMake Dynamic XML sitemap using PHPHow to create an animated old letter using an animated penAuto-load User Details on Mouse-Over using Ajax, Jquery and PHPFacebook style Search People and Products using Ajax, Jquery and PHPAuto-suggestion using Ajax and PHPAuto-suggest System using Ajax, Jquery and PHPUsername Availability Checker using Ajax and PHPSimple PHP Anti-Spam Captcha Contact Form Submission

Submit your Job or Project Today!

We can help you turn your idea into reality, take over your existing project, or extend your current development team.

Submit your idea job or project below and we will follow up with you shortly.

OUR OBJECTIVE

Our objective is to reach a place where our services will be highly regarded by businesses from various industrial domains for building their innovative busines solutions with our cutting-edge technological expertise, interactive designs and uncompromised quality.

OUR MISSION

We aspire to help businesses ranging from startups to enterprises, who reach out to us with their requirements, in achieving great lengths, expanding their reach, upscaling their products, and generate a large user-base with our outstanding and cost-effective services.

Please Wait....
Please Wait...