Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kishikawakatsumi/PEPhotoCropEditor
Image cropping library for iOS.
https://github.com/kishikawakatsumi/PEPhotoCropEditor
Last synced: 2 months ago
JSON representation
Image cropping library for iOS.
- Host: GitHub
- URL: https://github.com/kishikawakatsumi/PEPhotoCropEditor
- Owner: kishikawakatsumi
- License: mit
- Created: 2013-05-21T15:59:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-10-10T10:26:49.000Z (over 2 years ago)
- Last Synced: 2024-10-19T14:49:56.339Z (3 months ago)
- Language: Objective-C
- Size: 60 MB
- Stars: 1,087
- Watchers: 56
- Forks: 358
- Open Issues: 53
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - PEPhotoCropEditor - Image cropping library for iOS. (etc)
- awesome - PEPhotoCropEditor - Image cropping library for iOS. (etc)
README
PEPhotoCropEditor ![License MIT](https://go-shields.herokuapp.com/license-MIT-yellow.png)
=================[![Version](https://cocoapod-badges.herokuapp.com/v/PEPhotoCropEditor/badge.png)](https://cocoapod-badges.herokuapp.com/v/PEPhotoCropEditor/badge.png)
[![Platform](https://cocoapod-badges.herokuapp.com/p/PEPhotoCropEditor/badge.png)](https://cocoapod-badges.herokuapp.com/p/PEPhotoCropEditor/badge.png)
[![Build Status](https://travis-ci.org/kishikawakatsumi/PEPhotoCropEditor.png?branch=master)](https://travis-ci.org/kishikawakatsumi/PEPhotoCropEditor)
[![Analytics](https://ga-beacon.appspot.com/UA-4291014-9/PEPhotoCropEditor/README.md)](https://github.com/igrigorik/ga-beacon)PEPhotoCropEditor is image cropping library for iOS, similar to the Photos.app UI.
## Features
- Both iPhone/iPad available
- Works fine any device orientations
- Support pinch gesture to zoom
- Support rotation gesture## System requirements
- iOS 5.0 or higher## Installation
### CocoaPods
`pod 'PEPhotoCropEditor'`## Usage
**Use view controller component**
```objective-c
PECropViewController *controller = [[PECropViewController alloc] init];
controller.delegate = self;
controller.image = self.imageView.image;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navigationController animated:YES completion:NULL];
```**Or use the crop view directly**
```objective-c
self.cropView = [[PECropView alloc] initWithFrame:contentView.bounds];
[self.view addSubview:self.cropView];
```### Get the cropped image
**delegate method**
```objective-c
- (void)cropViewController:(PECropViewController *)controller didFinishCroppingImage:(UIImage *)croppedImage
{
[controller dismissViewControllerAnimated:YES completion:NULL];
self.imageView.image = croppedImage;
}
```**retrieve from view directly**
```objective-c
UIImage *croppedImage = self.cropView.croppedImage;
```### Keep crop aspect ratio while resizing
```objective-c
controller.keepingCropAspectRatio = YES;
``````objective-c
self.cropView.keepingCropAspectRatio = YES;
```### Specify crop rect by image size based
```objective-c
// e.g.) Cropping center square
CGFloat width = image.size.width;
CGFloat height = image.size.height;
CGFloat length = MIN(width, height);
controller.imageCropRect = CGRectMake((width - length) / 2,
(height - length) / 2,
length,
length);
``````objective-c
// e.g.) Cropping center square
CGFloat width = image.size.width;
CGFloat height = image.size.height;
CGFloat length = MIN(width, height);
self.cropView.imageCropRect = CGRectMake((width - length) / 2,
(height - length) / 2,
length,
length);
```### Reset back crop rect to original image size and rotation
```objective-c
[controller resetCropRect];
``````objective-c
[self.cropView resetCropRect];
```## License
[Apache]: http://www.apache.org/licenses/LICENSE-2.0
[MIT]: http://www.opensource.org/licenses/mit-license.php
[GPL]: http://www.gnu.org/licenses/gpl.html
[BSD]: http://opensource.org/licenses/bsd-license.phpPEPhotoCropEditor is available under the [MIT license][MIT]. See the LICENSE file for more info.