Service to automatically adjust images to match the background dimensions of the iPhone 11 Pro Max, while losslessly reducing the image size. | Transloadit

PHOTO EMBED

Sat Feb 25 2023 13:33:18 GMT+0000 (Coordinated Universal Time)

Saved by @deathcabkiddo #swift

// Install via Swift Package Manager:
// dependencies: [
//   .package(url: "https://github.com/transloadit/TransloaditKit", .upToNextMajor(from: "3.0.0"))
// ]}

// Auth
let credentials = Credentials(key: "YOUR_TRANSLOADIT_KEY")

// Init
let transloadit = Transloadit(credentials: credentials, session: "URLSession.shared")

// Add files to upload
let filesToUpload: [URL] = ...

// Execute
let assembly = transloadit.assembly(steps: [_originalStep, resizedStep, optimizeStep, exportedStep], andUpload: filesToUpload) { result in
  switch result {
  case .success(let assembly):
    print("Retrieved (assembly)")
  case .failure(let error):
    print("Assembly error (error)")
  }
}.pollAssemblyStatus { result in
  switch result {
  case .success(let assemblyStatus):
    print("Received assemblystatus (assemblyStatus)")
  case .failure(let error):
    print("Caught polling error (error)")
  }
content_copyCOPY

https://transloadit.com/demos/image-manipulation/resize-to-wallpaper-for-apple-iphone-11-pro-max/