FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme.

Overview

FlexibleImage

Swift Metal Platform License
Build Status Version Carthage compatible

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.


πŸ’‘ 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!


πŸ— 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)

1.9 ">
github "kawoou/FlexibleImage" ~> 1.9

Manually

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


πŸ“• Supported Features

Common

Type Parameter Comments
background() Color Background color.
opacity() Float Change the transparency of the image.
alphaProcess() Bool Whether to include an alpha value during image processing.
blendMode() CGBlendMode (Deprecated) Blend mode of the image
offset() CGPoint The position of the image to be a drawing.
rotate() radius: CGFloat
fixedSize: CGSize [Optional]
Rotate an image.
size() CGSize The size of the image to be a drawing.
outputSize() CGSize The size of a Output image.
scaling() CGSize Scaling the image (ratio)
margin() EdgeInsets Margin size
padding() EdgeInsets Padding size
corner() CornerType To clipping corner radius.
border() color: Color
lineWidth: CGFloat
radius: CGFloat
Drawing a border.
image() Run the pipeline to create the Output image.

Filter

Type Parameter Comments
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
threshold: Float [Optional]
smoothing: Float [Optional]
swizzling()
contrast() threshold: Float [Optional]
gamma() gamma: Float [Optional]

Blend

Type Parameter
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

Type Parameter Comments
algorithm() AlgorithmType Create an image by writing a formula directly on a pixel-by-pixel basis.
custom() ContextType Add processing directly using Core Graphics.

Generate

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

Pipeline (ImagePipeline class)

Type Parameter Return Comments
image() FIImage FIImage? Create the Output image.
image() CGImage CGImage? Create the Output image.
image() CVImageBuffer CGImage? Create the Output image.

🎁 Example


🏷 Changelog

  • 1.0
    • First Release.
  • 1.1
    • Add to clipping corner radius.
  • 1.2
    • Support tvOS, macOS.
  • 1.3
    • Support watchOS.
    • Added monochrome, sepia, vibrance, solarize, posterize filters.
    • Update resize methods.
  • 1.4
    • Add blur filter.
    • Optimize build time.
    • Setup TravisCI
    • Support carthage.
  • 1.5
    • Support Metal depending on the situation.
    • Added brightness, chromaKey, swizzling, contrast, gamma filters.
  • 1.6 (Hotfix!)
    • Fix issue Metal library path on Cocoapods.
  • 1.7
    • Pipelined implementation for stream processing.
    • Fix rendering bug due to image orientation (Thanks to Kwonyoon Kang)
  • 1.8
    • Support for Swift 4 and Xcode 9
  • 1.9
    • Support for Swift 4.1 and Xcode 9.3
  • 1.10
    • Support for Swift 4.2 and Xcode 10

πŸ’» Requirements

  • iOS 8.0+
  • tvOS 9.0+
  • macOS 10.10+
  • watchOS 2.0+
  • Swift 3.0+

πŸ”‘ License

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

You might also like...
Swifttty and easy camera framework for iOS.
Swifttty and easy camera framework for iOS.

SwiftttCamera Swifttty and easy camera framework for iOS. View Demo Β· Report Bug Β· Request Feature SwiftttCamera is a wrapper around AVFoundation that

Instant camera hybrid with multiple effects and filters written in Swift.
Instant camera hybrid with multiple effects and filters written in Swift.

Kontax Cam Download on the app store! No longer on the app store Kontax Cam is an instant camera built 100% using Swift for iOS. You can take your pho

A free, multiplatform SDK for real-time facial motion capture using blendshapes, and rigid head pose in 3D space from any RGB camera, photo, or video.
A free, multiplatform SDK for real-time facial motion capture using blendshapes, and rigid head pose in 3D space from any RGB camera, photo, or video.

mocap4face by Facemoji mocap4face by Facemoji is a free, multiplatform SDK for real-time facial motion capture based on Facial Action Coding System or

Custom iOS camera and photo picker with editing capabilities
Custom iOS camera and photo picker with editing capabilities

Overview Paparazzo is a component for picking and editing photos. Key Features πŸ“· Taking photos using camera πŸ“± Picking photos from user's photo libra

CameraButton - A simple camera button that can be used for photo and video capturing
CameraButton - A simple camera button that can be used for photo and video capturing

CameraButton A simple camera button that can be used for photo and video capturi

Extract opening hours tags from a camera image

OpeningHoursPhoto Extract opening hours tags from a camera image This project is no longer active. The latest development is taking part as part of Go

πŸ“Έ A wrapper for AVCaptureSession - The way easier to use the Camera.

Capturer A wrapper for AVCaptureSession - The way easier to use the Camera. Setting up let captureBody = CaptureBody( configuration: .init { $0.

Simple camera application for iOS that uploads pictures to WebDAV server or Dropbox quickly. Available on the AppStore.
Simple camera application for iOS that uploads pictures to WebDAV server or Dropbox quickly. Available on the AppStore.

Upupu Simple camera application for iOS that uploads pictures to WebDAV server or Dropbox quickly. Also available on the AppStore. Features Easy and f

AnylineFaceAuthentication pairs identity document scanning with a real-time liveness check utilizing the iPhone's camera, best suited for authenticating users over the internet.

AnylineFaceAuthentication AnylineFaceAuthentication pairs identity document scanning with a real-time liveness check utilizing the iPhone's camera, be

Comments
  • Support for Swift 4 and Xcode 9

    Support for Swift 4 and Xcode 9

    Please add support for swift 4 and Xcode 9. When building using swift 4 several build errors are returned.

    /Users/.../Pods/FlexibleImage/Sources/Filter/AddFilter.swift:49:32: 'setBuffer(_:offset:at:)' has been renamed to 'setBuffer(_:offset:index:)' /Users/.../Pods/Metal.MTLComputeCommandEncoder:42:17: 'setBuffer(_:offset:at:)' was obsoleted in Swift 4 /Users/.../Pods/FlexibleImage/Sources/Filter/BlurFilter.swift:89:17: Value of optional type 'MTLTexture?' not unwrapped; did you mean to use '!' or '?'? /Users/.../Pods/FlexibleImage/Sources/Filter/BlurFilter.swift:125:36: 'setTexture(_:at:)' has been renamed to 'setTexture(_:index:)' /Users/.../Pods/Metal.MTLComputeCommandEncoder:90:17: 'setTexture(_:at:)' was obsoleted in Swift 4 /Users/.../Pods/FlexibleImage/Sources/Filter/BlurFilter.swift:128:36: 'setTexture(_:at:)' has been renamed to 'setTexture(_:index:)' /Users/.../Pods/Metal.MTLComputeCommandEncoder:90:17: 'setTexture(_:at:)' was obsoleted in Swift 4 /Users/.../Pods/FlexibleImage/Sources/Filter/BlurFilter.swift:147:36: 'setBuffer(_:offset:at:)' has been renamed to 'setBuffer(_:offset:index:)' /Users/.../Pods/Metal.MTLComputeCommandEncoder:42:17: 'setBuffer(_:offset:at:)' was obsoleted in Swift 4

    Thanks

    opened by JoshAtPCI 3
  • Fix issues

    Fix issues

    • Optimize build time
    • Support carthage, swift package manager
    • Support TravisCI
    • Setup carthage build and deploy on TravisCI
    • Fix issue that expression was too complex to be solved in reasonable time
    • Remove blur() for watchOS
    • Update README.md

    Fix for #1 #2

    opened by kawoou 0
  • ChromaKeyFilter Transparency Issue.

    ChromaKeyFilter Transparency Issue.

    Hi,

    I have implemented ChromakeyFilter on image. I am using Green as Key color for filter but the output filtered image doesn't make all green pixels completely transparent. Green pixels are being transparent but not fully. Can you please suggest something?

    opened by amitsh4022 0
Releases(v1.10)
Owner
Jungwon An
Jungwon An
A SwiftUI app to filter & search runewords for Diablo II

Runewords App This small SwiftUI app have two purposes: Making a clean, fully SwiftUI app using all the latest iOS 16 / Xcode 14 features. Browse, sea

Thomas Ricouard 44 Dec 18, 2022
Core Image Filter Explorer & Showcase

Filterpedia Core Image Filter explorer Filterpedia is an iPad app for exploring (almost) the entire range of image filters offered by Apple's Core Ima

simon gladman 2.2k Dec 28, 2022
Applies filter to a selected image from the Gallery using Combine

CombinePhotoFiltering App CombinePhotoFiltering is an app that applies sepia and bloom to a selected picture from the Photos app. Highlights The app i

Mauricio Esteves 0 Nov 14, 2021
Vision Camera πŸ“Έ The Camera library that sees the vision.

Vision Camera ?? The Camera library that sees the vision. npm i react-native-vision-camera npx pod-install Documentation Guides API Ex

Marc Rousavy 3.5k Jan 5, 2023
πŸ“Έ iMessage-like, Image Picker Controller Provides custom features.

RAImagePicker Description RAImagePicker is a protocol-oriented framework that provides custom features from the built-in Image Picker Edit. Overview O

Rashed Al-Lahaseh 14 Aug 18, 2022
AirMessage Server, implemented natively in Swift

AirMessage Server AirMessage lets people use iMessage on the devices they like. AirMessage Server functions as the bridge between AirMessage client ap

AirMessage 90 Dec 29, 2022
A photo gallery for iOS with a modern feature set. Similar features as the Facebook photo browser.

EBPhotoPages ”A photo gallery can become a pretty complex component of an app very quickly. The EBPhotoPages project demonstrates how a developer coul

Eddy Borja 1.7k Dec 8, 2022
ImagePicker : an all-in-one camera solution for your iOS app

Description ImagePicker is an all-in-one camera solution for your iOS app. It lets your users select images from the library and take pictures at the

Γ–zgΓΌr Odabaşı 1 Dec 1, 2021
SwiftUI iOS app which applies CoreML Video Matting (background removal) model to the front camera stream

CoreML Camera Video Matting This is a simple iOS app which applies Video Matting (background removal) model to the front camera stream. Video Matting

Dmitry Voitekh 17 Dec 29, 2022
Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

Kanvas Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

Tumblr 267 Nov 24, 2022