/Cmg

Easy image filtering library of using Core Image.

Primary LanguageSwiftMIT LicenseMIT

Cmg

Version Swift 5.0 Platforms iOS Xcode 10.2

CmgImage

Easy image filtering library of using Core Image. (CIFilter)

Cmg is inspired by Filterpedia.

Requirements

  • Xcode 10+
OS Swift
v1.1.x iOS 8+ 3.0
v1.2.x iOS 9+ 3.2
v1.3.x iOS 9+ 4.1
v1.4.x iOS 9+ 4.2
v1.5.x iOS 10+ 5.0

Features

  • Image filtering (use CIFilter)
  • Filter grouping
  • Filter chaining
  • Slider support
  • Face detection (bonus)

Usage

Basics

Example for GaussianBlur filter

Default filter

let filteredImage = GaussianBlur().processing(image)

Edit for filter parameter

var filter = GaussianBlur()
filter.radius = 15.0
let filteredImage = filter.processing(image)

Edit for filter parameter (using closure)

let filteredImage = GaussianBlur()
      .configuration(){ filter in filter.inputRadius.setValue(15) }
      .processing(image)

Filter Group

let filterGroup = FilterGroup(name: "FilterGroupExample", [
    BoxBlur().configuration({ filter in filter.inputRadius.setValue(15) }),
    Vignette(),
    PhotoEffectMono(),
    ])

let filteredImage = filterGroup.processing(image)

Filter Chaining

let filteredImage = image.cmg_chain([
    ComicEffect(),
    GaussianBlur().configuration({ filter in
        filter.inputRadius.setValue(15)
    }),
    PerspectiveTile(imageSize: image.size).configuration({ filter in
        filter.inputTopLeft.setVector(Vector2(x: 118.0, y: 490.0).ciVector)
    }),
    ])

Demo

Please see Demo project. (Support Filter ShowCase) Please try on iOS Devices. Simulator is very slow...

Screenshot

Installation

CocoaPods

Cmg is available through CocoaPods. To install it, simply add the following line to your Podfile:

use_frameworks!

pod "Cmg"

Carthage

To integrate Cmg into your Xcode project using Carthage, specify it in your Cartfile:

github "xxxAIRINxxx/Cmg"

Use Image

Thanks pixabay

License

MIT license. See the LICENSE file for more info.