Skip to content
/ iris Public
forked from hodinkee/iris

A Swift framework for working with Imgix.

License

Notifications You must be signed in to change notification settings

adampilks/iris

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iris

Build Status Carthage Compatible Cocoapods Compatible

A Swift framework for working with Imgix.

Requirements

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

Installation

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)

About

A Swift framework for working with Imgix.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 92.7%
  • Objective-C 5.5%
  • Ruby 1.8%