Giter Club home page Giter Club logo

imagecacheresize's Introduction

ImageCacheResize

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:@"http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A"] andResize:CGSizeMake(30, 30) withContentMode:UIViewContentModeScaleAspectFit];


[imageview setImageWithURL:[NSURL URLWithString:@"http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A"] andCropToBounds:CGRectMake(0, 0, 100, 100)];

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

Bitdeli Badge

imagecacheresize's People

Contributors

anthonyfig avatar bitdeli-chef avatar travisjbeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagecacheresize's Issues

Doesn't cache full image

If I download an image. If I resize it, the resized image is cached, but not the original. If I want to access the original later, it's not cached and has to be downloaded again.

Cocoapod with dependencies

It looks like this project is an modification of SDWebImage. I would rather use it, when it takes SDWebImage as a dependency and build upon it further.

(The last update of this project is 3 months ago, while SDWebImage was last updated only a month ago. And I would like to keep updating SDWebImage as it progresses.)

Using this project would be a Cocoapod, with dependencies (SDWebImage (and maybe UIImage-Categories)), it would solve this, by allowing the users of these projects to independently upgrade these.

doubleSizeIfRetina should be called in all +WebCache methods that receive a size

"doubleSizeIfRetina" was added for some methods, but not for:

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

and

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

Since these methods are called by the shorter methods (without placeholder image), just move the doubleSizeIfRetina call to these methods.

Using Images to update Buttons

Hi,

I tried using Image Cache Resize for updating images for my app, however i also have button images which has to be downloaded from an URL...so can i use Image Cache for same purpose...If yes, could you please tell me how to update same. If i cant use this for Buttons, could u please help me find a solution where i can use something for loading button images and for UIImageview also....thanks in advance...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.