Cacomania: Splitting an Image in PHP


Splitting an Image in PHP

Guido Krömer - 19. December 2012 - Tags:

Some simple tasks ends up into a simple script. After trying to create a comparison image, which consists out of some screenshot taken at the same resolution with different application settings, details for example, I finally got mad creating this composed screenshot with GIMP.

The output generated could look like this one showing my blog in three different browsers splitted vertically, from left to right: Safari, Opera, Firefox. Vertically splitted view on Safari, Opera and Firefox.
Or splitted horizontally: Horizontal splitted view on Safari, Opera and Firefox.

Since PHP was already installed on my Mac, I used this to perform the task. Unfortunately only GD was installed and I was to lazy installing ImageMagic, this tiny script is based on GD.

Here is a screenshot of the nice :P interface for selecting the images, which can be found in the gist:Screenshot of the split image generator in php

Since I think the code is self-explaining, take a look to the gist below if you are interested: