Created
February 9, 2019 17:22
-
-
Save MihaelIsaev/9cbfdbd18b8f206e8ca34c8eaba8ec2f to your computer and use it in GitHub Desktop.
Little ImageMagick wrapper for Vapor Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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