Giter Club home page Giter Club logo

cropimageview's Introduction

CropImageView

Crop Images in SwiftUI.

A SwiftUI implementation of cropping images in selected areas. Here are some of its useful features:

  • Supports input with a UIImage and cropSize.
  • Supports dragging and dropping the input image
  • Supports scale for zooming in and out.
  • Supports saving the result UIImage
  • Supports showing in present and dismiss
  • Supports SwiftUI in iOS 13 and MacOS 10.15

Pull requests and suggestions welcome :)

Report Bug· Suggest a feature

Getting Started

To run the example project, clone the repo, and run.

Requirements

  • Xcode 11.5 and above
  • iOS 13 or MacOS 10.15 and above

Installation

As Swift Package

CropImageView is a swift package.

Alternatively, if you're unable to use SPM for some reason, you can import it manually.

Manual installation

Add CropImageView.swift to your project.

Usage

Simple use

var inputImage: UIImage {
    return UIImage(named: "demo") ??  UIImage(systemName: "sun.haze.fill")!
}

var body: some View {
    VStack {
        Button(action: {
            self.showCropView = true
        }) {
            Text("Show the crop view")
        }
        
        if self.croppedImage != nil {
            Image(uiImage: self.cropedImage!)
                .resizable()
                .scaledToFit()
                .padding()
        }
    }
    .sheet(isPresented: $showCropView,onDismiss:finishedCrop ) {
        CropImageView(inputImage: self.inputImage, resultImage: self.$croppedImage, cropSize: CGSize(width: 250, height: 250))
    }
}

func finishedCrop() {
    
}

Author

Xingfa Zhou

Contributor

License

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

cropimageview's People

Contributors

zhxf2012 avatar johngoren avatar egementrk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.