iOS library to manage Caches of images and Resize transformations
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Image Cache Resize.xcodeproj
Image Cache Resize


This library integrates two existing works:

The project is a single view iOS project that shows some of the transformations that can be done. Specially one of them is very useful and hard to achieve using remote images: When the developer wants to show a remote image that need to be shown with a specific width and height but must preserve the aspect ratio. The solution is something described by Trevor, which is to shrink the content just enough to fit the smaller dimension within the view. Some parts of the images are cropped and the dimensions of the UIImageView can be anticipated. In order to achieve this effect the dimensions of the original file should be known (which can be done by reading the first bytes of data, there several posts about this on StackOverflow).

New methods

New methods were added to UIImageView (additionally to the methods added by the original SDWebImage version).

- (void)setImageWithURL:(NSURL *)url andCropToBounds:(CGRect)bounds;

- (void)setImageWithURL:(NSURL *)url andResize:(CGSize)size withContentMode:(UIViewContentMode)mode;

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder andCropToBounds:(CGRect)bounds;

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options  andResize:(CGSize)size;

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options  andResize:(CGSize)size withContentMode:(UIViewContentMode)mode;

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options  andCropToBounds:(CGRect)bounds;

How to integrate into your project

  • Copy SDWebImage and UIImage+Resize folders content to your project.
  • Add the frameworks ImageIO.framework and MapKit.framework
  • Import UIImageView+WebCache.h.

How to use

Here are some examples using images in google:

[imageview setImageWithURL:[NSURL URLWithString:@""] andResize:CGSizeMake(30, 30) withContentMode:UIViewContentModeScaleAspectFit];

[imageview setImageWithURL:[NSURL URLWithString:@""] andCropToBounds:CGRectMake(0, 0, 100, 100)];

This project include some examples. Just clone and execute it.

Bitdeli Badge