---
title: "PHP based high resolution image combiner"
date: "2012-07-06"
modified: "2013-03-04"
path: "/71-php-based-high-resolution-image-combiner.html"
section: "/ramblings"
aliases:
  - "/71"
  - "/71-php-based-high-resolution-image-combiner"
  - "/71.html"
  - "/ramblings/71-php-based-high-resolution-image-combiner.html"
---

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.

<https://gist.github.com/3060960>

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