Swiftpack.co - nashysolutions/Vice as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by nashysolutions.
nashysolutions/Vice 3.0.0
A library / executable for resizing png images.
⭐️ 0
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/nashysolutions/Vice.git", from: "3.0.0")

Vice

iOS macOS

Products

  • A macOS command line tool for resizing png images.
  • An iOS library for resizing png images.

Usage: Command Line Tool

To resize to 100 width x 200 height.

$ vice ~/Desktop/Filename.png 100 200

To maintain aspect ratio

$ vice -r ~/Desktop/Filename.png 100 9999

See man page for more details.

Usage: iOS Library

The underlying core library is also available as a product (see installation below).

import Files // github.com:JohnSundell/Files
import Jaws

let file = try File(path: "~/myfile.png")
let targetSize = CGSize(width: width, height: height)
let jaws = Jaws(file: file, targetSize: targetSize, maintainRatio: false)
try await jaws.resize()

Installation

Vice Command Line Tool

$ git clone https://github.com/nashysolutions/Vice.git
$ cd Vice
$ swift run task install

If you have any issues with unix directories this article might be helpful.

iOS Library

let package = Package(
    name: "MyTool",
    products: [
        .executable(name: "tool", targets: ["MyTool"]),
    ],
    dependencies: [
        .package(name: "Vice", url: "https://github.com/nashysolutions/Vice.git", .upToNextMinor(from: "2.0.0"))
    ],
    targets: [
        .target(
            name: "MyTool", 
            dependencies: [
                .product(name: "Jaws", package: "Vice")
            ])
    ]
)

Swift 5.3 only knows how to skip dependencies not used by any product, which in this package is none. This is a limitation at the moment with the Swift package manager.

As a result, if you mark your target as depending on the Jaws product, Swift will download all the source for all the dependencies in this package.

Further, the entire Vice package will be downloaded so that files such as the README and other such documentation is available.

That being said, only the source required for Jaws will be compiled.

See thread on Swift forum.

GitHub

link
Stars: 0
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Vice 3.0.0
2 years ago

Introduces a breaking change - the resize function is now mutating. The original image is now available at the public interface.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics