Giter VIP home page Giter VIP logo

abimagewrapper's Introduction

MIT License

ABImageWrapper designed to handle image temporary caching. In case when you need to manage multiple UIImages which can't be loaded in memory all at once wrapper will store them in temporary directory. Wrapper object itself will handle only file pathes and load them when you need it. Because imageNamed method used in wrapper caches UIImages and clear them automatically on low memory warnings you don't need to take any aditional measures. Also wrapper can scale images and cache them for reuses between application launching in case your network server support this approach.

For example you can use ABImageWrapper when you provide user option to take from camera or choose from album multiple photos which will be later uploaded to server. Full sized photos can deplete all available memory very fast. In this case usualy you need to store them in some temporary directory and handle memory warning urself. Wrapper will make it a lot easyer.

Usage example:

//Create wrapper. You don't need to keep your image after wrapper is created ABImageWrapper* wrapper = [ABImageWrapper createWithUIImage:image];

//Get your original image UIImage* full_sized_image = [wrapper fullSized];

//Scaled image for some previews UIImage* small_image = [wrapper smallSize];

//128 128 image with quality of 0.5. Quality parameter is used for UIImageJPEGRepresentation UIImage* custom_image = [wrapper customSize:CGSizeMake(128, 128) withQuality:0.5];

//Cache image to use it next time application launch NSString* cache_id = [wrapper cacheForReuse];

//Create wrapper from cache. You can check if [cached_wrapper fullSized] is Nil later to check if image was cached and do something about if it wasn't. For example download image by cache id from server and cache it in application. ABImageWrapper* cached_wrapper = [ABImageWrapper createWithCacheID:cache_id];

//In case [cached_wrapper fullSized] is Nil and you downloaded corresponding image from server [cached_wrapper fillWithImage:image_from_server]; [cached_wrapper cacheForReuse];

Thats it.

P.S. Also in case you are concerned about storage memory use during application execution you can force clear temporary or gloabal cache folder. Please read comments before doing it. If you are still using UIImages created by wrapper you can get undefined behaviour depending from were those image already rendered or not.

abimagewrapper's People

Contributors

stdogbert avatar

Watchers

 avatar  avatar

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.