All Projects → imgix → Imgix Swift

imgix / Imgix Swift

Licence: bsd-2-clause
A Swift client library for generating URLs with imgix

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Imgix Swift

Serrata
Slide image viewer library similar to Twitter and LINE.
Stars: ✭ 322 (+1594.74%)
Mutual labels:  images, cocoapods, carthage
Shiny
Iridescent Effect View (inspired by Apple Pay Cash) ✨
Stars: ✭ 707 (+3621.05%)
Mutual labels:  cocoapods, carthage
Validatedpropertykit
Easily validate your Properties with Property Wrappers 👮
Stars: ✭ 701 (+3589.47%)
Mutual labels:  cocoapods, carthage
Preferences
⚙ Add a preferences window to your macOS app in minutes
Stars: ✭ 898 (+4626.32%)
Mutual labels:  cocoapods, carthage
Xlpagertabstrip
Android PagerTabStrip for iOS.
Stars: ✭ 6,671 (+35010.53%)
Mutual labels:  cocoapods, carthage
Zoomtransitioning
ZoomTransitioning provides a custom transition with image zooming animation and swiping the screen edge.
Stars: ✭ 670 (+3426.32%)
Mutual labels:  cocoapods, carthage
Gradients
🌔 A curated collection of splendid 180+ gradients made in swift
Stars: ✭ 719 (+3684.21%)
Mutual labels:  cocoapods, carthage
Flexiblepagecontrol
A flexible UIPageControl like Instagram.
Stars: ✭ 638 (+3257.89%)
Mutual labels:  cocoapods, carthage
Defaults
Swifty and modern UserDefaults
Stars: ✭ 734 (+3763.16%)
Mutual labels:  cocoapods, carthage
Dockprogress
Show progress in your app's Dock icon
Stars: ✭ 813 (+4178.95%)
Mutual labels:  cocoapods, carthage
Bfkit
BFKit is a collection of useful classes and categories to develop Apps faster.
Stars: ✭ 811 (+4168.42%)
Mutual labels:  cocoapods, carthage
Sdwebimageflplugin
A SDWebImage plugin to support GIF using FLAnimatedImage and category
Stars: ✭ 16 (-15.79%)
Mutual labels:  cocoapods, carthage
Interactivesidemenu
iOS Interactive Side Menu written in Swift.
Stars: ✭ 668 (+3415.79%)
Mutual labels:  cocoapods, carthage
Bluecap
iOS Bluetooth LE framework
Stars: ✭ 669 (+3421.05%)
Mutual labels:  cocoapods, carthage
Flyoverkit
360° flyover on a MKMapView 🚁
Stars: ✭ 666 (+3405.26%)
Mutual labels:  cocoapods, carthage
Koyomi
Simple customizable calendar component in Swift 📆
Stars: ✭ 716 (+3668.42%)
Mutual labels:  cocoapods, carthage
Statusalert
Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow in iOS-like way.
Stars: ✭ 809 (+4157.89%)
Mutual labels:  cocoapods, carthage
Stlocationrequest
Request the Location Services via a 3D 360° flyover MKMapView 🗺
Stars: ✭ 636 (+3247.37%)
Mutual labels:  cocoapods, carthage
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+3273.68%)
Mutual labels:  cocoapods, carthage
Zephyr
Effortlessly synchronize UserDefaults over iCloud.
Stars: ✭ 722 (+3700%)
Mutual labels:  cocoapods, carthage

imgix logo

imgix-swift is a client library for generating image URLs with imgix. Written in Swift, but can be used with Objective-C codebases as well.

CocoaPods Carthage compatible Build Status Supported Platforms License


Installation

// add the following to your Package.swift manifest, within the dependencies array

.package(url: "https://github.com/imgix/imgix-swift.git", from: "1.0.0")

// add the package name "ImgixSwift" to the list of named dependencies in your project target

.target(
    name: "YourSwiftProject",
    dependencies: ["ImgixSwift"]),

As of version 1.0.0 imgix Swift client is compatible with Swift 5.0.

The latest version compatible with Swift 4.0 is 0.4.3.

The latest version compatible with Swift 3.0 is 0.3.0.

Usage

Swift

// Import the framework
import ImgixSwift

// Set up an ImgixClient
let client = ImgixClient.init(host: "assets.imgix.net")

// Build a basic URL
client.buildUrl("dog.jpg") // => https://assets.imgix.net/dog.jpg

// Add some parameters
client.buildUrl("dog.jpg", params: [
  "w": 300,
  "h": 300,
  "fit": "crop"
]) // => https://assets.imgix.net/dog.jpg?fit=crop&h=300&w=300

Objective-C

If your project doesn't contain any other Swift code, make sure to set your target's Build Settings > Build Options > Embedded Content Contains Swift Code to YES.

// Import the framework
#import <ImgixSwift/ImgixSwift.h>

// Set up an ImgixClient
ImgixClient *client = [[ImgixClient alloc] initWithHost:@"assets.imgix.net"];

// Build a basic URL
[client buildUrl:@"dog.jpg"]; // => https://assets.imgix.net/dog.jpg

// Add some parameters
[client buildUrl:@"dog.jpg", params:@{
  @"w": @300,
  @"h": @300,
  @"fit": @"crop",
}]; // => https://assets.imgix.net/dog.jpg?fit=crop&h=300&w=300

Advanced Usage

Automatic Signing

If you're using a source that requires signed URLs, imgix-swift can automatically build and sign them for you.

let signedClient = ImgixClient.init(
  host: "imgix-library-secure-test-source.imgix.net",
  secureUrlToken: "EHFQXiZhxP4wA2c4"
)

signedClient.buildUrl("dog.jpg", params: [
  "bri": 50
]) // => https://imgix-library-secure-test-source.imgix.net/dog.jpg?bri=50&s=3b293930d9c288fb788657fd9ed8164f

Automatic Base64 Encoding

imgix-swift will automatically Base64-encode any parameter key ending in 64, according to the requirements of imgix's Base64 variant parameters.

let client = ImgixClient.init(host: "assets.imgix.net")

client.buildUrl("dog.jpg", params: [
  "w": 640,
  "txt64": "🐶 Puppy!",
  "txtfont64": "Avenir Next Demi,Bold",
  "txtalign": "center,top",
  "txtpad": 50,
  "txtshad": 10,
  "txtclr": "fff",
  "txtfit": "max",
  "txtsize": 50
]) // => https://assets.imgix.net/dog.jpg?txt64=8J-QtiBQdXBweSE&txtalign=center%2Ctop&txtclr=fff&txtfit=max&txtfont64=QXZlbmlyIE5leHQgRGVtaSxCb2xk&txtpad=50&txtshad=10&txtsize=50&w=640

URL Reconstruction

You can reconstruct existing URLs by using the ImgixClient#reconstruct method. Existing parameters on the input URL will be merged and/or overridden by passed params.

let client = ImgixClient.init(host: "assets.imgix.net")
let inputUrl = URL.init(string: "https://paulstraw.imgix.net/pika.jpg?w=300")!

client.reconstruct(originalURL: inputUrl, params: [
  "h": 300,
  "fit": "crop"
]) // => https://paulstraw.imgix.net/pika.jpg?fit=crop&h=300&w=300

What is the ixlib param

For security and diagnostic purposes, we default to signing all requests with the language and version of library used to generate the URL. This can be disabled by setting client.includeLibraryParam = false.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].