Hacking PicsEngine


The true story how I hacked the PicsEngine photo gallery system… to make the world better for the whole humankind, especially for the starving children in Africa.

No matter if you are a programmer or not, I have little doubt that the subheader invoked this sort of Hollywood image in your mind:

An expert programmer sits behind his computer and while typing real fast (and sometimes even pronouncing the code to himself) strings of code appear on his monitor like green spaghetti until a really cool animation draws a window with the text: “Access granted”.

Well, I cannot blame you. That’s why I threw in the rubbish about saving children in Africa. However, if you expect a story like that, you can stop reading straight away. This is going to be a boring description on how to tweak PicsEngine to handle uploaded images a bit better as I used the term “to hack” in a different meaning:

To tweak a product in order to improve its functionality without the explicit blessing of its author.

About PicsEngine

A few years ago I was looking for a photo gallery system - not just the frontend display of photos to website visitors but something that would also have a backend management of the photos. Free solutions that I found didn’t fit the bill and the paid systems were slightly expensive but PicsEngine worked nicely and at that time had a price tag of just 15 EUR. Perfect! However, it didn’t completely work the way I wanted so I came up with few changes of the code.


1. Using original images for resizing

When uploading an image, PicsEngine resizes your original image to a large one that is later used for display. When subsequently resizing an image, PicsEngine uses this large (already resized and compressed) version to create the new one. Do this a couple of times or simply decide to serve larger versions of all your images and the quality of the image will be appaling. Not something you want if you are a passionate photographer proud of your creations. While PicsEngine offers to save original version of the image when you upload it, this original version is used only to allow its download by the visitors. The first change I introduced then was to use this original version (if it exists) for all the resizing instead of the large version.

2. Preserving original images

The first change forces the use of the original image for resizing if it’s available. However, the option to store the original images can be turned off using the “Settings -> Photos -> Original photos conservated” option. As a developer you might want to force saving the original image and disallow editors to turn off this setting. The second change therefore intorduces a config file setting which enforces this.

3. Setting default resize option

Another problem was that during the upload images need to be resized. However, the uploader has to choose the size and obviously he/she might sometimes choose settings which are too small or unnecessarily large. Pre-selecting the “right” default option is another setting this patch introduces.

4. Disabling access to protected images in iPhone

The last thing that PicsEngine doesn’t really get right is handling of protected images when viewed on iPhones. These are simply displayed disregarding any protection. The patch changes this behaviour and instead protected images are not displayed.


All the changes are in separate files saved in the _over directory so you don’t have to use any patch utility or overwrite any files. Removing the patch is as easy as deleting those files. Obviously, if you already have some custom modified files in the _over directory, you will have to check if something would get overwritten and you would have to merge the code.

[DOWNLOAD patch v1.0.0][/files/code/picsengine_v3.5.3-patch_v1.0.0.zip]

DISCLAIMER: As I created those patches long time ago for a project that I don’t use myself, it might be that since then I forgot to mention something relevant or that the patches actually don’t work as expected. Therefore, backup everything and test the code on a copy of your web before using it in the LIVE version. I’m not taking any responsibility for any problems resulting from the use of that code.