Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kyome22/webpencoder

Swift WebP Encoder
https://github.com/kyome22/webpencoder

Last synced: about 1 month ago
JSON representation

Swift WebP Encoder

Awesome Lists containing this project

README

        

# WebPEncoder

Swift WebP Encoder

## Requirements

- Development with Xcode 16.0+
- Written in Swift 6.0
- swift-tools-version: 6.0
- Compatible with macOS 14.0+

## Usage

```swift
import AppKit
import WebPEncoder

guard let url = Bundle.module.url(forResource: "sample", withExtension: "jpg"),
let nsImage = NSImage(contentsOf: url),
let cgImage = nsImage.cgImage(forProposedRect: nil, context: nil, hints: nil) else {
return
}
do {
let webpData = try WebPEncoder().encode(cgImage, config: .preset(.picture, quality: 0.8, multithread: false))
webpData.write(to: saveURL)
} catch {
print(error.localizedDescription)
}
```

## Privacy Manifest

This library does not collect or track user information, so it does not include a PrivacyInfo.xcprivacy file.