Skip to content

rosberry/Cripper

Repository files navigation

Cripper

Customizable reusable component to get cropped image from provided one.

Features

  • Fully customizable UI
  • The possibility to use different quality images for according zoom scale
  • Specify crop shape to preview
  • Apply crop using bounding box or specified shape

Usage

  1. Create and customize view controller as you want:

    let cropViewController = CropperViewController(images: [.less(2): myLowQualityImage, 
                                                            .default: mySourceImage])
    cropViewController.clipBorderInset = 10
    cropViewController.cropOptions = [.circle()]
    cropViewController.mode = .path
  2. Present view controller. Please note, that CropperViewController does not contain UI controls to apply or decline cropped image that allows you to present it with any way using your custom controls:

    navigationController?.pushViewController(viewController, animated: true)
  3. Retrive a cropped image from CropperViewController.

    @objc private func acceptCropActionTriggered() {
        guard case let .normal(image) = cropperViewController.makeCroppResult() else {
            UINotificationFeedbackGenerator().notificationOccurred(.error)
            return
        }
        // TODO: Use provided image
    }

Installation

Depo

Depo is a universal dependency manager that combines Carthage, SPM and CocoaPods and provides common user interface to all of them.

To install Cripper via Carthage using Depo you need to add this to your Depofile:

carts:
  - kind: github
    identifier: rosberry/Cripper

Carthage

Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add the framework to your project.

SPM

Add SPM dependency to your Package.swift:

dependencies: [
    ...
    .package(url: "https://github.com/rosberry/Cripper")
],
targets: [
    .target(
    ...
        dependencies: [
            ...
            .product(name: "Cripper", package: "Cripper")
        ]
    )
]

Authors

About

This project is owned and maintained by Rosberry. We build mobile apps for users worldwide 🌏.

Check out our open source projects, read our blog or give us a high-five on 🐦 @rosberryapps.

License

The project is available under the MIT license. See the LICENSE file for more info.