What is SwiftGD?

This is a simple Swift wrapper for libgd, allowing for basic graphic rendering on server-side Swift where Core Graphics is not available. Although this package was originally written to accompany my book Server-Side Swift, it’s likely to be of general use to anyone wishing to perform image manipulation on their server.

SwiftGD wraps GD inside classes to make it easier to use, and provides the following functionality:

  • Loading PNGs and JPEGs from disk.
  • Writing images back to disk as PNG or JPEG.
  • Creating new images at a specific width and height.
  • Resizing to a specific width or height.
  • Cropping at a location and size.
  • Flood filling a color from a coordinate.
  • Drawing lines
  • Reading and writing individual pixels.
  • Stroking and filling ellipses and rectangles.
  • Flipping images horizontally and vertically.
  • Basic effects: pixelate, blur, colorize, and desaturate.

SwiftGD manages GD resources for you, so the underlying memory is released when your images are destroyed.

Overview

  • Pricing: Free
  • Resource Link: https://github.com/twostraws/swiftgd
  • Resource Maker: Paul Hudson
  • Mobile Platform Destination: iOS Apps
  • Mobile Platform Support: Native iOS
  • Programming Languages: Swift