Swift package · v0.1.0

KLSubjectVision

Create square subject or room thumbnails from a CGImage.

A synchronous thumbnail processor using Apple Vision, Core Image, and Core Graphics. It reports whether the result used a subject cutout, fallback, or room treatment.

Platforms
iOS 17+ · macOS 14+
Toolchain
Swift 6.0+
License
MIT
Dependencies
None

Functions

  • Vision foreground instance masks
  • Aspect-fit cutout with explicit inset
  • Aspect-fill room and fallback treatment
  • Injectable extraction for deterministic tests

Not included

It processes CGImage values; it does not load platform images, schedule work, encode files, choose cache keys, or own attachment storage.

Install with SwiftPM

Package.swiftSwift
.package(url: "https://github.com/KoenLee1023/KLSubjectVision.git", from: "0.1.0")

Usage

Integration exampleSwift
let output = SubjectThumbnailProcessor().process(
    source,
    request: .subject(pixelSize: 512, inset: 28)
)

guard let output else { return }
display(output.image, path: output.kind)
SubjectThumbnailProcessor

Transforms one CGImage synchronously without shared mutable state.

SubjectThumbnailRequest

Selects subject or room treatment with explicit pixel geometry.

SubjectThumbnailOutput

Returns the square image and cutout, fallback, or room path.

Demo apps

Subject Studio

Compare injected cutout, forced fallback, and source geometry.