Toucan is a Swift library that provides a clean, quick API for processing images. It greatly simplifies the production of images, supporting resizing, cropping and stylizing your images.
- Easy and smart resizing
- Elliptical and rounded rect masking
- Mask with custom images
- Chainable image processing stages
- 100% Unit Test Coverage - once image loading in XCTests are fixed!
- Add crop options for crop location & faces
- Add enhancement filters to beautify images
- Add stylize filters
- Add rotation and flip support
- Lazy evaluation of image contexts to prevent having to create and close multiple contexts during method chaining
- Xcode 7
- iOS 8.0+
As of version 0.4, Toucan only supports Swift 2. Use version 0.3.x for the latest Swift 1.2 compatible release
- Include the
Toucan
framework by dragging it into your project and import the library in your code usingimport Toucan
Currently there are issues loading the library using pod 'Toucan'
which is pending changes from Cocoapods.
Toucan provides two methods of interaction - either through wrapping an single image within a Toucan instance, or through the static functions, providing an image for each invocation. This allows for some very flexible usage.
Create an instance wrapper for easy method chaining:
let resizedAndMaskedImage = Toucan(image: myImage).resize(CGSize(width: 100, height: 150)).maskWithEllipse().image
Or, using static methods when you need a single operation:
let resizedImage = Toucan.Resize.resizeImage(myImage, size: CGSize(width: 100, height: 150))
let resizedAndMaskedImage = Toucan.maskWithEllipse(resizedImage)
Resize the contained image to the specified size. Depending on what fitMode
is supplied, the image may be clipped, cropped or scaled.
Toucan(image: myImage).resize(size: CGSize, fitMode: Toucan.Resize.FitMode)
or
Toucan.Resize.resizeImage(image: UIImage, size: CGSize, fitMode: FitMode = .Clip) -> UIImage
FitMode drives the resizing process to determine what to do with an image to make it fit the given size bounds.
Alter the original image with a mask; supports ellipse, rounded rect and image masks.
Example images used under Creative Commons with thanks to:
- Please fork this project
- Implement new methods or changes in the
Toucan.swift
file. - Write tests in the
ToucanTests
folder. - Write appropriate docs and comments in the README.md
- Submit a pull request.
Raise an Issue or hit me up on Twitter @gavinbunney
Toucan is released under an MIT license. See LICENSE for more information.