Skip to content

Instantly share code, notes, and snippets.

@MihaelIsaev
Created February 9, 2019 17:22
Show Gist options
  • Save MihaelIsaev/9cbfdbd18b8f206e8ca34c8eaba8ec2f to your computer and use it in GitHub Desktop.
Save MihaelIsaev/9cbfdbd18b8f206e8ca34c8eaba8ec2f to your computer and use it in GitHub Desktop.
Little ImageMagick wrapper for Vapor Swift
//
// ImageMagick.swift
// App
//
// Created by Mihael Isaev on 01.08.2018.
//
import Foundation
import Vapor
import Core
class ImageMagick {
///convert dragon.gif -resize 64x64 resize_dragon.gif
public static func resize(fromPath: String, toPath: String, width: Int, height: Int) {
let wk = Process()
let stdout = Pipe()
#if !os(Linux)
wk.launchPath = "/usr/local/bin/convert" //which convert - to find where it is
#else
wk.launchPath = "/usr/bin/convert" //which convert - to find where it is
#endif
wk.arguments = [fromPath, "-resize", "\(width)x\(height)", toPath]
wk.standardOutput = stdout
wk.launch()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment