Iris
A Swift framework for working with Imgix.
Install / Use
/learn @hodinkee/IrisREADME
Iris
A Swift framework for working with Imgix.
Requirements
| Xcode | Swift | iOS | tvOS | macOS | | :---: | :---: | :---: | :---: | :---: | | 9.0 | 4.0 | 8.0 | 9.0 | 10.10 |
Installation
Carthage
github "hodinkee/Iris" ~> 3.0
CocoaPods
pod "Iris", "~> 3.0"
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)
Related Skills
node-connect
349.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.7kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
