Skip to content

guidolodetti/UIImage-resize-and-crop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

UIImage - Resize and Crop

Simple class extension to resize and crop UIImages with just two functions.

Usage

Add both files to your project, then import the class extension where you need it.

Examples
// Imports the class extension
#import "UIImage+ResizeAndCrop.h"

// Resizes an image to 100x100 pixels
UIImage * exampleImage = [UIImage imageNamed:@"yourImageFile"];
UIImage * resizedImage = [exampleImage resizeToSize:CGSizeMake(100.0f, 100.0f)];
if (resizedImage != nil) {
	// Your image was resized
} else {
	// Something went wrong
}

// Crops an image to 100x100 pixels, 150px from left and 200px from top
UIImage * exampleImage = [UIImage imageNamed:@"yourImageFile"];
UIImage * croppedImage = [exampleImage cropToRect:CGRectMake(150.0f, 200.0f, 100.0f, 100.0f)];
if (croppedImage != nil) {
	// Your image was cropped
} else {
	// Something went wrong
}

About

Simple class extension to resize and crop UIImages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published