GRKImageCrop
A UIImage category which provides “visible” pixel cropping capabilities.
A given image can be rectangularly cropped based on calculated insets to “visible” pixels. Visible pixels are those whose alpha component are greater than or equal to a given alpha threshold.
Available on github: https://github.com/levigroker/GRKImageCrop
Installing
If you’re using CocoPods it’s as simple as adding this to your
Podfile
:
pod 'GRKImageCrop'
otherwise, simply add the contents of the GRKImageCrop
subdirectory to your
project.
Documentation
To use, simply import UIImage+GRKImageCrop.h
:
#import "UIImage+GRKImageCrop.h"
Then you can use the category to create a cropped image from a given image:
[image cropImageBelowAlphaThreshold:0.0f completion:^(UIImage *croppedImage, NSError *error) {
if (croppedImage)
{
//Use croppedImage
}
else
{
//Hanlde error
}
}];
The only expected error would be memory related.
Additional documentation is available in UIImage+GRKImageCrop.h
and example usage
can be found in the GRKImageCropTestApp
.
Disclaimer and Licence
- Inspiration was taken from:
- I have made use of image cropping code from http://stackoverflow.com/a/25293588/397210
- This work is licensed under the Creative Commons Attribution 3.0 Unported License. Please see the included LICENSE.txt for complete details.