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.
Features
- Easy and smart resizing
- Elliptical and rounded rect masking
- Mask with custom images
- Chainable image processing stages
Requirements
- Xcode 10.0+
- iOS 11.0+
Setup
- 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 Usage
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.
Resizing
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)
Fit Mode
FitMode drives the resizing process to determine what to do with an image to make it fit the given size bounds.
Masking
Alter the original image with a mask; supports ellipse, rounded rect and image masks.
Ellipse Mask
Path Mask
Rounded Rect Mask
Image Mask
Example Images
Example images used under Creative Commons with thanks to:
Contributing
- 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.
Contact
Raise an Issue or hit me up on Twitter @gavinbunney
License
Toucan is released under an MIT license. See LICENSE for more information.