Skip to Main Content

Code Samples

Here you can find a small collection of sample code I’ve written, as an example of my capabilities and skills.

PHP-Smart-Crop (PHP Class)

Smart-Crop is a proof of concept for a method of intelligently cropping images.  Imagine you need a user-provided image that will be presented to viewers in three different resolutions, depending on the client accessing it.  The user uploads a 500×200 image.  You could display cropping controls and force the user to choose an area to display for each client, but that adds friction and confusion to the user experience, Instead, smart-cropping analyzes the image by color and entropy to find the most “interesting” area (at least as best as an algorithm can identify it).  Then it weights the “direction of interest” to identify which portion of the image to show more of, while maintaining the position of the focus as close to a rule of thirds line or center line as possible. Example: These images are generated live from the same source image.  The only variable given to the class is target width and height.  (Photo credit to Wikipedia Commons)

Smart Crop 250×150

Smart Crop 150×150

Smart Crop 100×150

avatarGuess (procedural PHP function)

avatarGuess is a tricky little piece of code I wrote for a CRM dashboard that was never used.  It attempts to provide avatars to people in the CRM, based on their email address, by checking several public sources of user photos, such as gravatar, google profiles, facebook, and skype.  Unfortunately, it never got to see the light of day, due to privacy concerns.  Example: Demo Page In my experience, the function finds an exact match about 20% of the time, and a guess about 60% of the time.  Try [email protected], if you’re having trouble getting one to work.

jSlabify (jQuery Plugin)

Although originally a fork from slabtext by freqdec, I stripped out all of his code in the process of rewriting the slabbing algorithm.  The current codebase is entirely my work. jSlabify takes a block of text and a box with dimensions, and splits the text into lines of varying sizes, to best fit the box.  It is compatible with responsive and fluid designs. Example: Demo Page
Three examples of slabbing settings

Three examples of slabbing settings