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
- Xcode 10.0+
- iOS 11.0+
- Install using CocoaPods: https://cocoapods.org/pods/Toucan
- or manually include the
Toucan
framework by dragging it into your project and import the library in your code usingimport Toucan
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)
Typically, the instance version is a bit cleaner to use, and the one you want.
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)
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.