A lightweight and fast image loader for iOS written in Swift.

Overview

ImageLoader

Build-Status CocoaPods Carthage compatible codecov.io license

ImageLoader is an instrument for asynchronous image loading written in Swift. It is a lightweight and fast image loader for iOS.

Features

  • Simple methods with UIImageView Category.
  • Control Loader to resume, suspend and cancel with URL.
  • A module for cache can be set by yourself and default cache (Disk) uses disk spaces and un-uses memory.
  • Loading images is handled by ImageLoader, not UIImageView.
  • After image view start loading another image, previous loading task is possible to live with caching.
  • Support NSURL, String and NSURLComponents by URLLiteralConvertible
  • Optimize to use memory when image is set.
  • Support image type .jpeg, .png
  • Comprehensive Unit Test Coverage

Requirements

  • iOS 8.0+
  • Xcode 7.0+ Swift 2.0
ImageLoader Xcode Swift
0.13.+ 9.0+ 4.0
0.12.+ 8.1+ 3.0
0.11.+ 8.0+ 3.0
0.10.0 8.0+ 2.3
0.9.x 7.3.1 2.2

If your project's target need to support iOS5.x or 6.x, use ImageLoader. It's A lightweight and fast image loader for iOS written in Objective-C.

Installation

CocoaPods

pod 'ImageLoader'

Carthage

To integrate ImageLoader into your Xcode project using Carthage, specify it in your Cartfile:

github "hirohisa/ImageLoaderSwift" ~> 0.6.0

Usage

ImageLoader

load

ImageLoader.request(with: url, onCompletion: { _ in })

UIImageView

imageView.load.request(with: url)

or

imageView.load.request(with: url, onCompletion: { _ in })

License

ImageLoader is available under the MIT license.

Comments
  • duplicate cells

    duplicate cells

    I have a list of 13 URLs that I need to load from images. I use ImageLoaderSwift to load the images into my app, but I am getting duplicates. My cellForItemAtIndexPath just reads:

    cell.image.load(self.myURLs[indexPath.item])

    the image below shows a few of the duplicate cells i'm talking about (there are more but off screen)

    capture d ecran 2016-01-07 a 17 15 03

    I searched issues but couldn't find anything similar to this.

    There are the urls I am trying to load, by the way:

    let myURLs = ["http://imgur.com/a/VeCYT", "http://i.imgur.com/qYQDyFZ.jpg", "http://i.imgur.com/ebyIE6A.gif", "http://i.imgur.com/4Uv5XOK.jpg", "http://i.imgur.com/8j7tf4k.gif", "http://i.imgur.com/pAyQ2MA.gif", "http://i.imgur.com/rVNe8m3.jpg", "http://i.imgur.com/apL0vsp.jpg", "http://i.imgur.com/XsdBXMZ.png", "http://i.imgur.com/4j0slvch.gif", "http://imgur.com/a/KojbY", "http://i.imgur.com/3kSFolM.png", "http://imgur.com/a/LFQxo", "http://imgur.com/a/OMefU"]

    opened by JoeyBodnar 8
  • Invalid CGBitmapContext

    Invalid CGBitmapContext

    I receive the following warning when using this library:

    CGBitmapContextCreateImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

    This is on line 81 of ImageLoader.swift.

    opened by camdub 8
  • Image size downloaded not true for the first time after upgrading to 0.6.1

    Image size downloaded not true for the first time after upgrading to 0.6.1

    cell.contentImageView.load(URL, placeholder: nil, completionHandler: {[weak self] URL, image, error, cacheType in if let weakSelf = self, image = image { print("image size w:(image.size.width), h:(image.size.height)") // Do something with image } }) image link: https://files.parsetfss.com/d1c4d42b-52b9-427b-98f8-a9d816751efd/tfss-29090e17-fd55-4959-891e-a3134d84152f-seBCKRC2qQ.png This is them sample code I am using. The problem doesn't happen in 0.5.1, that the image size is downloaded as full size (500x325) by observe the log. After pull 0.6.1 I found the problem that the image size in log line is divided by 2, mean (250x162.6), so the image displayed with wrong size. Wrong size issue of the image only happen if the is not downloaded yet. If it is already cached, thing is good. Hope you can help me. Thanks.

    opened by gloryluu 6
  • No option to disable url encoding

    No option to disable url encoding

    I have urls that have already been url encoded and I wish to load it through the library.

    Unfortunately, I think an earlier commit (https://github.com/hirohisa/ImageLoaderSwift/commit/20ef32ff715dd1470276040b906ad5b24e893aac) is causing it to assume all urls are raw.

    My use case is actually quite common and simple I think. I have a webservice that is signing expiring images hosted from amazon s3. Amazon s3 notoriously uses a lot of url-unsafe characters in its signatures, including the literal %. However, it intends that clients send a literal % and not the url-encoded form of %25 - the extra 2 characters break the signature

    This is the line that is doing the conversion. https://github.com/hirohisa/ImageLoaderSwift/blob/20ef32ff715dd1470276040b906ad5b24e893aac/ImageLoader/ImageLoader.swift#L24

    opened by anacronw 5
  • Transparent background images become white?

    Transparent background images become white?

    I got that problem while testing the downloading:

    moodImageView.load("http://mooddy.officience.com/uploads/media/default/564e/91/thumb_564e9152582c2ee3217b23c6_default_small.png")

    The problem doesnt happen if I use this:

    let url = NSURL(string:"http://mooddy.officience.com/uploads/media/default/564e/91/thumb_564e9152582c2ee3217b23c6_default_small.png")! moodImageView.image = UIImage(data: NSData(contentsOfURL: url)!)

    opened by gloryluu 5
  • Fatal error if url has spaces

    Fatal error if url has spaces

    Hi @hirohisa

    I got fatal error for url:

    http://img.banggood.com/thumb/gallery/upload/2012/panxihua/SKU113576/yuan/SKU113576 (1).jpg
    

    Screenshot: https://www.dropbox.com/s/3c7le7t8gps6758/Screenshot%202015-06-18%2019.15.54.png?dl=0

    Best regards, Alexey

    opened by AlexeyFreelancer 5
  • Change loaded image

    Change loaded image

    Is there an option of changing the loaded image? For example, I need to crop the image for a specific size. Here is my current code which doesn't work:

        cell.courseImageView.load(course.imageUrl, placeholder: nil) { URL, image, error, cacheType in
            if let anImage = image {
                let croppedImage = Util.imageByCroppingImage(anImage, size: cell.frame.size)
    
                if cacheType == CacheType.None {
                    let transition = CATransition()
                    transition.duration = 0.5
                    transition.type = kCATransitionFade
                    cell.courseImageView.layer.addAnimation(transition, forKey: nil)
                }
    
                cell.courseImageView.image = croppedImage
            }
        }
    
        return cell
    }
    
    opened by guybashan 4
  • Fixed synchronization issue

    Fixed synchronization issue

    Fixed a a synchronization issue which was causing a malloc error, this was due to an edge case where if you scroll too quickly it was reading and writing at the same time.

    Credit also goes to @emersonmalca for helping debug.

    Anyways I'm sure it can be more robust if we can add some cancellation to it, because at a certain point storage gets overloaded and you don't see anymore images.

    opened by ZkHaider 3
  • dos not support redirect url

    dos not support redirect url

    could you please support redirected url

    if you open url http://market.mesbahey.com\imagefile\1DgdX3bTK3 it is redirect to image file and will fail to load image

    if you see this lib for android it is have more options and you can Benefits from it . It is Amazing lib for java app

    https://github.com/nostra13/Android-Universal-Image-Loader

    thanks in advance

    opened by oazya500 3
  • Images sometimes don't load

    Images sometimes don't load

    I am xCode 8.0, Swift3 configuration

    From my app I am using this call: cardImage.load("Some url", placeholder: placeholder)

    First time the image loads OK, but sometimes it fails when loading from cache. I have isolated the problem in imageLoader_load method. Sometimes the if let wSelf = self, let selfUrl = wSelf.url, let image = image , selfUrl == url { condition failes. When I brek it down on lines it failes on selfUrl == url part. I can't really explain why because I don't see error in your code. I fixed it by excluding this part of condition from code. I believe that this condition is introduced as a fail safe cause the process of downloading is asynchronous and the method can be called from table views which use reusable cells or something like that.

    Also I have a suggestion: Can you please make image transition modular from outside, and remove condition cacheType == CacheType.none cause I woud like to animate transition no matter if the image comes from the cache, or at least make it optional.

    thx

    opened by AntonijoDev 3
  • Error with Data+ImageLoader in pods

    Error with Data+ImageLoader in pods

    I'm constantly getting this error in the Data+ImageLoader.swift after installing the pods Expression pattern of type '[Int]' cannot match values of type '[UInt8]'

    Anyone have any idea what might be ?

    I already did a pod repo update, pod update, deleted podfile.lock and pods folder

    aaaaaaaa

    opened by raphahenrique 2
  • Could not load PNG file

    Could not load PNG file

    Whenever I load PNG file, I am getting this error: Error Domain=Imageloader Code=-999 "Failure when convert image" UserInfo={NSLocalizedFailureReason=Failure when convert image}

    opened by krish23 0
  • Some requests never finish

    Some requests never finish

    I used the swift 4.2 pull request.

    Whenever a call starts, I print "s URL". For finish "f URL". Here is the output:

    "s" "https://storage.googleapis.com/.../n5677twuadpd8sts%26y.jpg"
    "s" "https://storage.googleapis.com/.../sr90j5ag7va%2B_owfcz.jpg"
    "s" "https://storage.googleapis.com/.../chmtq16rhwcnigo3e6.jpg"
    "f" "https://storage.googleapis.com/.../chmtq16rhwcnigo3e6.jpg"
    "s" "https://storage.googleapis.com/.../chmtq16rhwcnigo3e6.jpg"
    "f" "https://storage.googleapis.com/.../chmtq16rhwcnigo3e6.jpg"
    "s" "https://storage.googleapis.com/.../chmtq16rhwcnigo3e6.jpg"
    "s" "https://storage.googleapis.com/.../r0e6s2r0tbucbjq4ky.jpg"
    "f" "https://storage.googleapis.com/.../r0e6s2r0tbucbjq4ky.jpg"
    "s" "https://storage.googleapis.com/.../r0e6s2r0tbucbjq4ky.jpg"
    "f" "https://storage.googleapis.com/.../r0e6s2r0tbucbjq4ky.jpg"
    "f" "https://storage.googleapis.com/.../chmtq16rhwcnigo3e6.jpg"
    

    some calls, for example the first one, never finish. I'll just use another library, but I thought maybe you'd like to know.

    opened by yspreen 0
  • Crash on receive data

    Crash on receive data

    Hello, I got a crash on one test device

    report from crashlytics https://pastebin.com/yGTFtZpU

    func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { guard let loader = getLoader(with: dataTask) else { return } 40 ->> loader.operative.receiveData.append(data) }

    opened by M9236059933 6
  • Propose Logo

    Propose Logo

    Hi @hirohisa . I'm graphic disigner. I would like to know if you are interested that I make a logo for your project? If you allowed me, i"ll make logo for your project and it's free.

    opened by mirzazulfan 0
  • Error handling for Url Image

    Error handling for Url Image

    I'm getting nil for the error in imageloader when the server returns BlobNotFound. Do you have a way to catch this in the completion handler?

    the message from the server is: BlobNotFound The specified blob does not exist. RequestId:2f7a64bc-0001-00a8-1ee8-fb80c1000000 Time:2016-08-21T20:14:55.4485653Z

    opened by vindicatesociety 0
Owner
Hirohisa Kawasaki
Hirohisa Kawasaki
Very easy to use image loader for swift

Silo Silo is a extremely easy to use and very basic image loader for iOS built in Swift. if you use Silo in your project please let me know! Version 2

Jose Quintero 17 Dec 17, 2022
🍁πŸ₯“ Lightweight and fast Swift library for image downloading, caching and transformations

MapleBacon Introduction MapleBacon is a lightweight and fast Swift library for downloading and caching images. Example The folder Example contains a s

Jan Gorman 335 Nov 1, 2022
Animated sharingan loader for iOS projects.

Animated sharingan loader for iOS projects. This is a fun project created using SwiftUI with love for the Uchiha clan. More types of eyes to come with tons of customizations...

Manas Aggarwal 16 Nov 30, 2022
AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

Dmytro Anokhin 1k Jan 4, 2023
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

Evgenii Neumerzhitckii 330 Sep 9, 2022
Fast and simple OCR library written in Swift

⛔️ This Project is deprecated and no longer gets maintained! Please use Apple's Vision framework instead of SwiftOCR. It is very fast, accurate and mu

Nicolas Camenisch 4.5k Dec 29, 2022
Fast and simple OCR library written in Swift

⛔️ This Project is deprecated and no longer gets maintained! Please use Apple's Vision framework instead of SwiftOCR. It is very fast, accurate and mu

Nicolas Camenisch 4.5k Dec 29, 2022
Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

Twitter 1.8k Dec 17, 2022
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

Adnan Yousaf 11 Jan 10, 2022
Lightweight and customisable async image loading in SwiftUI. Supports on-disk storage, placeholders and more!

Asyncrounously download and display images in Swift UI. Supports progress indicators, placeholders and image transitions. RemoteImageView Asyncrounous

Callum Trounce 192 Dec 7, 2022
πŸ“· A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 3, 2023
πŸ“· A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 2, 2023
A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

QRDecode A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image. QRDecode

David Phillip Oster 2 Oct 28, 2022
An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.

CZImageEditor CZImageEditor is an instagram-like image editor with clean and intuitive UI. It is pure swift and can apply preset filters and customize

null 8 Dec 16, 2022
Image-cropper - Image cropper for iOS

Image-cropper Example To run the example project, clone the repo, and run pod in

Song Vuthy 0 Jan 6, 2022
Convert the image to hexadecimal to send the image to e-paper

ConvertImageToHex Convert the image to hexadecimal to send the image to e-paper Conversion Order // 0. hex둜 λ³€ν™˜ν•  이미지 var image = UIImage(named: "sample

Hankyeol Park 0 Feb 26, 2022
A Fast and Complete Swift Drawing Library

FastDraw A Fast and Complete Swift Drawing Library Description FastDraw is a high performance and highly extensible Drawing Library that supports Appl

Collin Zhang 18 Nov 14, 2022
Agrume - πŸ‹ An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 2022
Image picker with custom crop rect for iOS written in Swift (Ported over from GKImagePicker)

WDImagePicker Ever wanted a custom crop area for the UIImagePickerController? Now you can have it with WDImagePicker. Just set your custom crop area a

Wu Di 96 Dec 19, 2022