Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
/ iris Public archive

A Swift framework for working with Imgix.

License

Notifications You must be signed in to change notification settings

hodinkee/iris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

af59d75 · Nov 12, 2015

History

52 Commits
Nov 12, 2015
Nov 12, 2015
Nov 12, 2015
Nov 12, 2015
Nov 11, 2015
Nov 12, 2015

Repository files navigation

Iris

Build Status

A Swift framework for working with Imgix.

Requirements

  • Swift 2.1
  • iOS 8.0, tvOS 9.0, or OS X 10.10

Installation

Carthage:

github "hodinkee/iris"

Usage

Let's say you have an Imgix Web Folder or Amazon S3 source setup. You then have a plain URL to an image resource like the one below.

let imageURL = NSURL(string: "https://my-source.imgix.net/path/to/my/image")

Now, the original image is a rather large 1920x1080px photo of Yosemite, but your app displays it in a 320x180pt view. It would be incredibly wasteful of bandwidth and memory to download the original image. Let's fix that by asking Imgix to resize it for us.

let displayScale = imageView.traitCollection.displayScale
let imageOptions = ImageOptions(width: 320, height: 180, scale: displayScale)
let resizedImageURL = imageURL?.imgixURL(imageOptions: imageOptions)

Want to ensure the resized image is in the JPEG file format with a quality of 50? Just configure the options!

imageOptions.format = .JPEG
imageOptions.quality = 50

If you need to sign your Imgix URLs, whether just for security's sake or because you're using a Web Proxy Source, there's a way to do that too!

let signingOptions = SigningOptions(host: "my-source.imgix.net", token: "FOObar123")
let signedImageURL = imageURL?.imgixURL(imageOptions: imageOptions, signingOptions: signingOptions)