Swiftpack.co -  asaday/EzImageLoader as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Swift Image downloader
.package(url: "https://github.com/asaday/EzImageLoader.git", from: "3.6.0")


EzImageLoader is easy-to-use library for lading Images over HTTP/HTTPS. EzImageLoader is associated with EzHTTP.


  • Simplest image loading
  • Just write shorter code
  • Support WebP
  • Support GIF format: of course, supporting animated GIFs
  • Extending UIImage and UIImageView
  • HTTP/HTTPS requests using EzHTTP


  • iOS 9.0+
  • Xcode 11+



Add EzImageLoader to the dependencies in your Podfile.

pod 'EzImageLoader'

Sample Podfile is here.

Swift Package Manager

You can also install EzImageLoader using Swift Package Xcode11 later

File->Swift Packages->Add Package Dependency...



Begin by importing the EzImageLoader

import EzImageLoader

In addition, import EzHTTP for creating URLRequest easily.

import EzHTTP



Get for an image.

let iv = UIImageView(frame: view.bounds)
ImageLoader.get("https://httpbin.org/image/png") {iv.image = $0.image}

Get an image and resizing

let mSize = CGSize(width: 200, height: 200)
ImageLoader.get(urlStr, size: mSize) {iv.image = $0.image}


Get an image with NSURLRequest. Note that "HTTP.createRequest()" creates URLRequest with EzHTTP.

let iv = UIImageView(frame: view.bounds)
let req = HTTP.createRequest(.GET, "https://httpbin.org/image/png", params: [:], headers: [:])
ImageLoader.request(req!) {iv.image = $0.image}

Request and resize the image.

let mSize = CGSize(width: 200, height: 200)
ImageLoader.request(req!, size:mSize) {iv.image = $0.image}


You can get some information about a request. ResultReason is enumeration type and gives status of the result.

  • $0.image UIImage?
  • $0.reason enum ResultReason
  • $0.decodeTime TimeInterval
  • $0.downloadTime TimeInterval
let iv = UIImageView(frame: view.bounds)
let mSize = CGSize(width: 300, height: 200)
ImageLoader.get("https://www.gstatic.com/webp/gallery/4.webp", size: mSize) {
    iv.image = $0.image
    print("Reason", $0.reason)
    print("Decode Time", $0.decodeTime)
    print("Download Time", $0.downloadTime)

// Reason downloaded
// Decode Time 0.0499059557914734
// Download Time 0.553457021713257


Async request .requestASync() or .getASyinc() for using in except main task.

let req = HTTP.createRequest(.GET, "https://httpbin.org/image/png", params: [:], headers: [:])
let img1:UIImage? = ImageLoader.requestASync(req!)

let img2:UIImage? = ImageLoader.getASync("https://httpbin.org/image/png")
let img3:UIImage? = ImageLoader.getASync(urlStr, headers: ["Custom-Content":":D"])

UIImageView Extension

EzImageLoader extends UIImageView. It's very simple to use.

let iv = UIImageView(frame: view.bounds)

// With additional headers
iv.loadURL("https://httpbin.org/image/png", headers: ["Custom-Content":"HAHAHA"])

// Apply Filter
let ilFilter = ImageLoader.Filter.resizer(CGSize(width: 320, height: 320))
iv.loadURL("https://httpbin.org/image/png", filter: ilFilter)

Use with URLRequest.

let iv = UIImageView(frame: view.bounds)
let req = HTTP.createRequest(.GET, "https://httpbin.org/image/png", params: [:], headers: [:])

// Apply Filter
let ilFilter = ImageLoader.Filter.resizer(CGSize(width: 280, height: 280))
iv.loadRequest(req!, filter: ilFilter)

UIImage Extension

Resizing a image for UIImage.

let img:UIImage = #imageLiteral(resourceName: "SpImage").resize(CGSize(width: 280, height: 280))

Get an image as Data and decode to UIImage. You can use animation GIFs and WebPs well.

let gifURL = "https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif"
HTTP.get(gifURL) {
    let img = UIImage.decode($0.data!)
    iv.image = img


Stars: 2
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.


Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API