PHP based high resolution image combiner

Written by Peter Davies on .

We needed a PHP based high resolution image combiner that took two folders:

  1. Low Resolution - any file file type
  2. High Resolution - again any file file type
and to make a little more complicated the images existed multiple times throughout a complex folder hierarchy.

The following script uses PHP 5's RecursiveDirectoryIterator to loop through the folders and then uses the returned file object to get the size of the image performing a simple check based on the logic that the largest image is most likely the high-res version.

The file is executed by running it from the command line as such: php ./imagecombine.php