SimpleImage 3.0

Back in 2011, I released the first version of SimpleImage for PHP β€” an open source project for working with images.

Today, version 3.0 has landed, and there's a lot to love about it.

Overview

Here's how it works at a glance:

<?php
try {
// Create a new SimpleImage object
$image = new \claviska\SimpleImage();

// Magic! ✨
$image
->fromFile('image.jpg') // load image.png
->autoOrient() // adjust orientation based on exif data
->resize(320, 200) // resize to 320x200 pixels
->flip('x') // flip horizontally
->colorize('DarkBlue') // tint dark blue
->border('black', 10) // add a 10 pixel black border
->overlay('watermark.png', 'bottom right') // add a watermark image
->toFile('new-image.png', 'image/png') // convert to PNG and save a copy to new-image.png
->toScreen(); // output to the screen

// And much more! πŸ’ͺ
} catch(Exception $err) {
// Handle errors
echo $err->getMessage();
}

Requirements

  • PHP 5.6+
  • GD extension

Features

  • Supports reading, writing, and converting GIF, JPEG, PNG, WEBP formats.
  • Reads and writes files and data URIs.
  • Manipulation: crop, resize, overlay/watermark, adding TTF text
  • Drawing: arc, border, dot, ellipse, line, polygon, rectangle, rounded rectangle
  • Filters: blur, brighten, colorize, contrast, darken, desaturate, edge detect, emboss, invert, pixelate, sepia, sketch
  • Utility methods: color adjustment, darken/lighten color, exif data, height/width, mime type, orientation
  • Color arguments can be passed in as any CSS color (e.g. `LightBlue`), a hex color, or an RGB(A) array.
  • Support for alpha-transparency (GIF, PNG, WEBP)
  • Chainable methods
  • Uses exceptions
  • Load with Composer or manually (just one file)

Download

Download the source from GitHub.

Differences from 2.x

The readme has a list of changes from the 2.x version of SimpleImage.

Simple, Beautiful Publishing

This website is powered by Postleaf, an open source blogging platform I built myself. Check it out if you’re looking for a fresh, modern approach to content management.

Author avatar

About the author

Cory LaViska is a founder, web developer, and bootstrapper based in Orlando, Florida. Need to get in touch? You can connect with him on Twitter. Looking for a simple, no-worry CMS for your clients? Try my Surreal CMS!