Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaidpathan/zimagecropper
A Swift 5 repo to crop image in any shape.
https://github.com/zaidpathan/zimagecropper
crop-image ios swift swift5
Last synced: 2 days ago
JSON representation
A Swift 5 repo to crop image in any shape.
- Host: GitHub
- URL: https://github.com/zaidpathan/zimagecropper
- Owner: ZaidPathan
- License: mit
- Created: 2015-11-12T18:17:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-26T17:09:59.000Z (over 4 years ago)
- Last Synced: 2025-02-08T02:51:12.560Z (12 days ago)
- Topics: crop-image, ios, swift, swift5
- Language: Swift
- Homepage:
- Size: 2.74 MB
- Stars: 235
- Watchers: 9
- Forks: 40
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ZImageCropper
[](https://travis-ci.org/ZaidPathan/ZImageCropper)
[](https://cocoapods.org/pods/ZImageCropper)
[](https://cocoapods.org/pods/ZImageCropper)
[](https://cocoapods.org/pods/ZImageCropper)ZImageCropper is a simplest way to crop image to any shapes you like.

## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
### Cocoapods
ZImageCropper is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'ZImageCropper'
```### Swift Package Manager
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into Xcode and the Swift compiler.
If you are using Xcode 11 or later:
1. Click `File`
2. `Swift Packages`
3. `Add Package Dependency...`
4. Specify the git URL for `ZImageCropper`.
```swift
https://github.com/ZaidPathan/ZImageCropper
```### Manual
Add ` ZImageCropper.swift` and ` ZImageCropperView.swift` files to your project.## Usage
### Crop using AI (Or programmatically)Crop image using following code,
```swift
let croppedImage = ZImageCropper.cropImage(ofImageView: yourImageView, withinPoints: [
CGPoint(x: 0, y: 0), //Start point
CGPoint(x: 100, y: 0),
CGPoint(x: 100, y: 100),
CGPoint(x: 0, y: 100) //End point
])
```Note : Make sure you provide valid points, points must be >=2 in count.
### Crop using user touches,
**Step 1:** Add `UIImageView` to your `StoryBoard/XIB` and give it a Class Name: `ZImageCropperView`**Step 2:** Run the app and see cropping is enable to your `UIImageView`
**Step 3:** Add `@IBOutlet` of your `UIImageView` and call method `imageView.cropImage()` to crop selected layer by user.
## Author
Zaid Pathan
## Contributor
[Zaid Pathan](http://github.com/ZaidPathan), [Devansh Vyas](http://github.com/devanshvyas)
## License
ZImageCropper is available under the MIT license. See the LICENSE file for more info.