In this tutorial, I will guide how to make the images collage using PHP GD library and MySQL.
Import the Db schema from folder "db->imagecollage.sql"
Set the DB name and credentials in connection.php file
Make the virtual host, to run the site as a domain on the local machine like imagecollage.dev or localhost.imagecollage.com etc.
That's it :) you are good to go.
Run the imagecollage.dev or localhost.imagecollage.com in your favorite browser as mine is chrome.
- functions.php
- pics (folder)
- master.jpg
These 3 components are whole collage soul.
functions.php file contains all the functions do the following functionality
- Insert the positions of images in the DB.
- Make the collage using images position from DB and pictures from pics folder
Here is list of functions
- readMasterImageAndSetPositionsInDb()
- makeCollage()
- getRandomEmptyPosition()
- getOccupiedPositions()
- getPastedImages()
- insertPosition()
- saveNewImage($params)
- lastedImages()
- getFileExtension($path)
- scanFolderAndAddTheImagesInDb()
In this folder all the pictures of collage, those will be posted on the master picture would be here.
This is the base of collage, all the pictures from pics folder would be paste on this and thus the way collage will be created.
- Pictures name in DB and in pics folder should be same
- In functions.php there are two constants named X and Y. These constants are responsible for height and width of the images on collage and also the number of images on collage. Increase the X and Y values will decrease the images on the collage and vice versa.