PhotoEditKit

Getting started

Add auto photo editing to your app.

Install the library, pass in a photo, and get back the edit it needs. Everything runs on the device: no account, no API key, no network request.

iOS & macOS

iOS 17.6+macOS 15+Swift Package Manager
  1. Step 1

    Install with Swift Package Manager

    In Xcode, choose File → Add Package Dependencies…, enter https://github.com/8kdesign/PhotoEditKit and add the PhotoEditKit library to your app target. Or declare it in your own Package.swift:

    .package(url: "https://github.com/8kdesign/PhotoEditKit", from: "1.2.7")
  2. Step 2

    Let the AI edit a photo

    Give the AI a small upright copy (512 px is plenty) and the photo's ImageIO properties. You get back an EditConfig to render on the full-size photo, or nil when the photo is already good. Run it off the main thread.

    import ImageIO
    import PhotoEditKit
    
    guard let source = CGImageSourceCreateWithURL(photoURL as CFURL, nil) else { return }
    let properties = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [String: Any]
    
    // A small upright copy is all the AI needs, and much faster than full size.
    let options = [
        kCGImageSourceCreateThumbnailFromImageAlways: true,
        kCGImageSourceCreateThumbnailWithTransform: true,
        kCGImageSourceThumbnailMaxPixelSize: 512,
    ] as CFDictionary
    guard let small = CGImageSourceCreateThumbnailAtIndex(source, 0, options) else { return }
    
    // Off the main thread: this measures the photo.
    if let config = AIPostProcessingHelper.topSuggestion(for: small, metadata: properties),
       let original = CIImage(contentsOf: photoURL, options: [.applyOrientationProperty: true]) {
        let edited: CIImage = original.applyingEditConfig(config)
    } else {
        // The photo is already good. Keep it as it is.
    }

    Pass the properties from the original file. The EXIF exposure lets the AI tell a night street from an underexposed shot, so dark-on-purpose photos aren't brightened.

  3. Step 3

    Show a picker of suggestions

    Want people to choose? Ask for up to ten ranked suggestions, each with a title, an EditConfig and a ready-made thumbnail. Pass the full-size photo so grain can be measured.

    // Off the main thread, with the full-size photo.
    let suggestions = AIPostProcessingHelper.suggestions(for: uiImage, metadata: properties)
    for suggestion in suggestions {
        suggestion.title      // e.g. "Brighten"
        suggestion.config     // EditConfig to apply
        suggestion.thumbnail  // small rendered preview, ready for a picker
    }

    On macOS the API is the same: use NSImage wherever the examples use UIImage.

  4. Step 4

    Read the full guide

    The README covers the rest: building an editor with EditController, HDR export, Live Photos, video editing and every setting.

Android

Android 10+arm64-v8acompileSdk 36Kotlin 2.2+
  1. Step 1

    Add the Maven repository

    PhotoEditKit is published in a Maven repository hosted on GitHub. Add it in settings.gradle.kts:

    dependencyResolutionManagement {
        repositories {
            google()
            mavenCentral()
            maven("https://raw.githubusercontent.com/8kdesign/PhotoEditKit-Android/main/maven") {
                content { includeGroup("com.logicui") }
            }
        }
    }
  2. Step 2

    Add the dependency

    Then add the library to your app module's build.gradle.kts. The AI engine is built for 64-bit ARM only, so limit your app to arm64-v8a:

    android {
        defaultConfig {
            ndk { abiFilters += "arm64-v8a" }
        }
    }
    
    dependencies {
        implementation("com.logicui:photoeditkit:1.2.7")
    }
  3. Step 3

    Let the AI edit a photo

    Decode the photo upright with ImageDecoder and pass its ExifInterface. suggestions is a suspend function that runs in the background. Render the best one with renderedEdit, off the main thread.

    import android.graphics.ImageDecoder
    import androidx.exifinterface.media.ExifInterface
    import com.logicui.photoeditkit.PhotoEditKit
    
    suspend fun autoEdit(context: Context, uri: Uri): Bitmap {
        val resolver = context.contentResolver
        // ImageDecoder applies the EXIF orientation, so the bitmap is upright.
        val photo = ImageDecoder.decodeBitmap(ImageDecoder.createSource(resolver, uri))
        val exif = resolver.openInputStream(uri)?.use { ExifInterface(it) }
    
        val result = PhotoEditKit.suggestions(context, photo, exif)  // runs in the background
        val best = result.suggestions.firstOrNull() ?: return photo
        return withContext(Dispatchers.Default) { PhotoEditKit.renderedEdit(photo, best.config) }
    }
  4. Step 4

    Show a picker of suggestions

    Each suggestion has a title in the device's language, an EditConfig and a 240 px thumbnail, ready for a picker. A well-balanced photo can return none.

    val result: SuggestionResult = PhotoEditKit.suggestions(context, photo, exif)
    for (suggestion in result.suggestions) {
        suggestion.title      // "Brighten", in the device's language
        suggestion.config     // EditConfig to apply
        suggestion.thumbnail  // 240 px rendered preview, ready for a picker
    }
  5. Step 5

    Read the full guide

    The README covers the rest: previews with EditPreviewView, Ultra HDR, Motion Photos, video editing and every setting.