Home

Awesome

<img alt="FlexibleImage" src="https://github.com/kawoou/FlexibleImage/raw/master/Preview/Cover.png" style="max-width: 100%"> <center> <p align="center"> <img alt="Swift" src="https://img.shields.io/badge/Swift-4.1-orange.svg"> <a href="https://developer.apple.com/metal/" target="_blank"><img alt="Metal" src="https://img.shields.io/badge/Apple-Metal-ff00ff.svg"></a> <a href="http://cocoadocs.org/docsets/FlexibleImage" target="_blank"><img alt="Platform" src="http://img.shields.io/cocoapods/p/FlexibleImage.svg?style=flat"></a> <a href="https://github.com/kawoou/FlexibleImage/blob/master/LICENSE" target="_blank"><img alt="License" src="http://img.shields.io/cocoapods/l/FlexibleImage.svg?style=flat"></a> <br> <a href="https://travis-ci.org/kawoou/FlexibleImage" target="_blank"><img alt="Build Status" src="https://travis-ci.org/kawoou/FlexibleImage.svg?branch=master"></a> <a href="http://cocoadocs.org/docsets/FlexibleImage" target="_blank"><img alt="Version" src="http://img.shields.io/cocoapods/v/FlexibleImage.svg?style=flat"></a> <a href="https://github.com/Carthage/Carthage" target="_blank"><img alt="Carthage compatible" src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat"></a> </p> </center>

FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme. When you write code in the "Method Chaining" style, the effect is applied in the appropriate order.

You may want to see Examples section first if you'd like to see the actual code.

<br>

💡 Usage

Code

Example Image

import UIKit

import FlexibleImage

/// Generate Example
let image1 = UIImage
    .circle(
        color: UIColor.blue,
        size: CGSize(width: 100, height: 100)
    )!
    
    .adjust()
    .offset(CGPoint(x: 25, y: 0))
    .margin(UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5))
    .padding(UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 15))
    .normal(color: UIColor.white)
    .border(color: UIColor.red, lineWidth: 5, radius: 50)
    .image()!
    
    .adjust()
    .background(color: UIColor.darkGray)
    .image()


/// Effect Example
let image2 = UIImage(named: "macaron.jpg")!
    .adjust()
    .outputSize(CGSize(width: 250, height: 250))
    .exclusion(color: UIColor(red: 0, green: 0, blue: 0.352941176, alpha: 1.0))
    .linearDodge(color: UIColor(red: 0.125490196, green: 0.058823529, blue: 0.192156863, alpha: 1.0))
    .hardMix(color: UIColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1.0))
    .image()


/// Mix Example
let image3 = image2!.adjust()
    .append(
        image1!.adjust()
            .outputSize(CGSize(width: 250, height: 250))
            .alpha(0.5)
    )
    .image()

/// Clipping Example
let image4 = image3!.adjust()
    .corner(CornerType(25))
    .image()

/// Pipeline
let pipeline = ImagePipeline()
        .exclusion(color: UIColor(red: 0, green: 0, blue: 0.352941176, alpha: 1.0))
        .linearDodge(color: UIColor(red: 0.125490196, green: 0.058823529, blue: 0.192156863, alpha: 1.0))

let image5 = pipeline.image(image2)
let image6 = pipeline.image(image1)

Playground

Use CocoaPods command $ pod try FlexibleImage to try Playground!

<br>

🏗 Installation

CocoaPods (For iOS 8+ projects)

KWDrawerController is available on CocoaPods. Add the following to your Podfile:

/// Swift 3
pod 'FlexibleImage', '~> 1.7'

/// Swift 4
pod 'FlexibleImage', '~> 1.9'

Carthage (For iOS 8+ projects)

github "kawoou/FlexibleImage" ~> 1.9

Manually

You can either simply drag and drop the Sources folder into your existing project.

<br>

📕 Supported Features

Common

TypeParameterComments
background()ColorBackground color.
opacity()FloatChange the transparency of the image.
alphaProcess()BoolWhether to include an alpha value during image processing.
blendMode()CGBlendMode(Deprecated) Blend mode of the image
offset()CGPointThe position of the image to be a drawing.
rotate()radius: CGFloat<br/>fixedSize: CGSize [Optional]Rotate an image.
size()CGSizeThe size of the image to be a drawing.
outputSize()CGSizeThe size of a Output image.
scaling()CGSizeScaling the image (ratio)
margin()EdgeInsetsMargin size
padding()EdgeInsetsPadding size
corner()CornerTypeTo clipping corner radius.
border()color: Color<br/>lineWidth: CGFloat<br/>radius: CGFloatDrawing a border.
image()Run the pipeline to create the Output image.

Filter

TypeParameterComments
greyscale()threshold: Float [Optional]
monochrome()threshold: Float [Optional]
invert()
sepia()
vibrance()vibrance: Float [Optional]
solarize()threshold: Float [Optional]
posterize()colorLevel: Float [Optional]
blur()blurRadius: Float [Optional]Not supported by watchOS.
brightness()brightness: Float [Optional]
chromaKey()color: FIColor<br/>threshold: Float [Optional]<br/>smoothing: Float [Optional]
swizzling()
contrast()threshold: Float [Optional]
gamma()gamma: Float [Optional]

Blend

TypeParameter
normal()Color
multiply()Color
lighten()Color
darken()Color
average()Color
add()Color
subtract()Color
difference()Color
negative()Color
screen()Color
exclusion()Color
overlay()Color
softLight()Color
hardLight()Color
colorDodge()Color
colorBurn()Color
linearDodge()Color
linearBurn()Color
linearLight()Color
vividLight()Color
pinLight()Color
hardMix()Color
reflect()Color
glow()Color
phoenix()Color
hue()Color
saturation()Color
color()Color
luminosity()Color

Post-processing

TypeParameterComments
algorithm()AlgorithmTypeCreate an image by writing a formula directly on a pixel-by-pixel basis.
custom()ContextTypeAdd processing directly using Core Graphics.

Generate

TypeComments
rect()Create a rectangular image.
circle()Create a circle image.
append()Combine images to create a single image.

Pipeline (ImagePipeline class)

TypeParameterReturnComments
image()FIImageFIImage?Create the Output image.
image()CGImageCGImage?Create the Output image.
image()CVImageBufferCGImage?Create the Output image.
<br>

🎁 Example

<br>

🏷 Changelog

<br>

💻 Requirements

<br>

🔑 License

FlexibleImage is under MIT license. See the LICENSE file for more info.