All Projects → guoyingtao → Mantis

guoyingtao / Mantis

Licence: mit
A photo cropping tool which mimics Photo.app written by Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Mantis

Alloycrop
The best and tiny size mobile cropping component - 做最好且最小的移动裁剪组件
Stars: ✭ 907 (+235.93%)
Mutual labels:  crop, cropping
Pixelsdk
The modern photo and video editor for your iPhone / iPad app. A fully customizable image & video editing iOS Swift framework.
Stars: ✭ 192 (-28.89%)
Mutual labels:  crop, cropping
React Easy Crop
A React component to crop images/videos with easy interactions
Stars: ✭ 1,093 (+304.81%)
Mutual labels:  crop, cropping
React Native Image Crop Picker
iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
Stars: ✭ 5,261 (+1848.52%)
Mutual labels:  crop, cropping
react-native-avatar-crop
Highly customisable <Crop /> component for React Native < 💅 >
Stars: ✭ 47 (-82.59%)
Mutual labels:  crop, cropping
Flutter image cropper
A Flutter plugin for Android and iOS supports cropping images
Stars: ✭ 723 (+167.78%)
Mutual labels:  crop, image-cropper
Cropiwa
📐 Configurable Custom Crop widget for Android
Stars: ✭ 2,185 (+709.26%)
Mutual labels:  crop, image-cropper
Prynttrimmerview
A set of tools to trim, crop and select frames inside a video
Stars: ✭ 553 (+104.81%)
Mutual labels:  crop, cropping
Android Imagecropview
android image crop library
Stars: ✭ 225 (-16.67%)
Mutual labels:  crop, cropping
Igrphototweaks
Drag, Rotate, Scale and Crop
Stars: ✭ 212 (-21.48%)
Mutual labels:  crop, cropping
Tocropviewcontroller
A view controller for iOS that allows users to crop portions of UIImage objects
Stars: ✭ 4,210 (+1459.26%)
Mutual labels:  crop, cropping
mpv-scripts
dynamic-crop.lua script for mpv player/lib.
Stars: ✭ 43 (-84.07%)
Mutual labels:  crop, cropping
Svelte Easy Crop
A Svelte component to crop images with easy interactions
Stars: ✭ 80 (-70.37%)
Mutual labels:  crop, cropping
Rskimagecropper
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
Stars: ✭ 2,371 (+778.15%)
Mutual labels:  crop, cropping
react-drop-n-crop
An opinionated implementation of react-dropzone and react-cropper
Stars: ✭ 17 (-93.7%)
Mutual labels:  crop, image-cropper
tinycrop
Pure JavaScript image crop library
Stars: ✭ 62 (-77.04%)
Mutual labels:  crop, image-cropper
tiny
compress data for better performance
Stars: ✭ 21 (-92.22%)
Mutual labels:  crop
node-imaginary
Minimalist node.js command-line & programmatic API client for imaginary
Stars: ✭ 94 (-65.19%)
Mutual labels:  crop
cropper
Bildbearbeitung im REDAXO-Medienpool: Zuschneiden, Drehen, Spiegeln.
Stars: ✭ 33 (-87.78%)
Mutual labels:  crop
sic
🦜 Accessible image processing and conversion from the terminal. Front-end for image-rs/image.
Stars: ✭ 96 (-64.44%)
Mutual labels:  crop

Mantis

swift 5.0 badge platform iOS badge license MIT badge

Mantis

Mantis is a swift 5.0 library that mimics most interactions in the Photos.app on an iOS device. You can use the CropViewController of Mantis with default buttons, or you can add your own buttons under the "customized" mode.

Mantis Mantis Mantis Mantis Mantis Mantis Mantis Mantis Mantis Mantis

Credits

The crop and rotation feature are strongly inspired by TOCropViewController and IGRPhotoTweaks.

The rotation dial is inspired by 10clock

Thanks Leo Dabus for helping me to solve the problem of cropping an ellipse image with transparent background https://stackoverflow.com/a/59805317/288724

Requirements

  • iOS 11.0+
  • Xcode 10.0+

Install

CocoaPods

pod 'Mantis', '~> 1.4.13'

Carthage

github "guoyingtao/Mantis"

Usage

Mantis doesn't dismiss CropViewController anymore since 1.2.0. You need to dismiss it by yourself. For CropViewControllerDelegate protocol, cropViewControllerDidCancel becomes non-optional, and cropViewControllerWillDismiss is deprecated

  • Create a cropViewController in Mantis with default config and default mode

You need set (cropViewController or its navigation controller).modalPresentationStyle = .fullscreen for iOS 13 when the cropViewController is presented

let cropViewController = Mantis.cropViewController(image: <Your Image>)
  • The caller needs to conform CropViewControllerDelegate
public protocol CropViewControllerDelegate: class {
    func cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation)
    func cropViewControllerDidFailToCrop(_ cropViewController: CropViewController, original: UIImage) // optional
    func cropViewControllerDidCancel(_ cropViewController: CropViewController, original: UIImage)
}
  • CropViewController has two modes:

    • normal mode

    In normal mode, you can use a set of standard CropViewController photo editing features.

Mantis

let cropViewController = Mantis.cropViewController(image: <Your Image>)
  • customizable mode

This mode includes the standard cropping feature, while enabling users to customize other edit features.

Mantis

let cropViewController = Mantis.cropCustomizableViewController(image: <Your Image>)
  • Add your own ratio
            // Add a custom ratio 1:2 for portrait orientation
            let config = Mantis.Config()
            config.addCustomRatio(byVerticalWidth: 1, andVerticalHeight: 2)            
            <Your Crop ViewController> = Mantis.cropViewController(image: <Your Image>, config: config)
            
            // Set the ratioOptions of the config if you don't want to keep all default ratios
            let config = Mantis.Config() 
            //config.ratioOptions = [.original, .square, .custom]
            config.ratioOptions = [.custom]
            config.addCustomRatio(byVerticalWidth: 1, andVerticalHeight: 2)            
            <Your Crop ViewController> = Mantis.cropViewController(image: <Your Image>, config: config)
  • If you always want to use only one fixed ratio, set Mantis.Config.presetFixedRatioType = alwaysUsingOnePresetFixedRatio
    <Your Crop ViewController>.config.presetFixedRatioType = .alwaysUsingOnePresetFixedRatio(ratio: 16.0 / 9.0)

When choose alwaysUsingOnePresetFixedRatio, fixed-ratio setting button does not show.

  • If you want to hide rotation dial, set Mantis.Config.showRotationDial = false
  • If you want to use ratio list instead of presenter, set Mantis.CropToolbarConfig.ratioCandidatesShowType = .alwaysShowRatioList
public enum RatioCandidatesShowType {
    case presentRatioList
    case alwaysShowRatioList
}
  • If you build your custom toolbar you can add your own fixed ratio buttons
// set a custom fixed ratio
cropToolbarDelegate?.didSelectRatio(ratio: 9 / 16)
  • If you want to set different crop shape, set Mantis.Config.cropShapeType
public enum CropShapeType {
    case rect
    case ellipse(maskOnly: Bool = false)
    case roundedRect(radiusToShortSide: CGFloat, maskOnly: Bool = false)
}
  • If you want to apply transformations when showing an image, set Mantis.Config.presetTransformationType
public enum PresetTransformationType {
    case none
    case presetInfo(info: Transformation)
    case presetNormalizedInfo(normailizedInfo: CGRect)
}

Please use the transformation infomation obtained previously from delegate method cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation).

Mantis Mantis Mantis Mantis

Demo code

        let cropViewController = Mantis.cropViewController(image: <Your Image>)
        cropViewController.delegate = self
        <Your ViewController>.present(cropViewController, animated: true)
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].