MagickPublishPlugin

0.3.0

An ImageMagick plugin for the Publish static site generator
mvolpato/magickpublishplugin

What's New

v0.3.0

2020-07-15T21:00:50Z

Assume user adds ImageMagick to its PATH

ImageMagick plugin for Publish

A Publish plugin that helps running ImageMagick commands while building any Publish website.

Installation

To install it into your Publish package, add it as a dependency within your Package.swift manifest:

let package = Package(
    ...
    dependencies: [
        ...
        .package(url: "https://github.com/mvolpato/magickpublishplugin", from: "0.3.0")
    ],
    targets: [
        .target(
            ...
            dependencies: [
                ...
                "MagickPublishPlugin"
            ]
        )
    ]
    ...
)

Then import SplashPublishPlugin wherever you’d like to use it:

import MagickPublishPlugin

For more information on how to use the Swift Package Manager, check out this article, or its official documentation.

Usage

You need ImageMagick version 6 to use the optimizeForWeb(imagesInFolder: String) method.

You can use other methods with version 7.

The plugin can then be used within any publishing pipeline like this:

import MagickPublishPlugin
...
try DeliciousRecipes().publish(using: [
...
.installPlugin(.optimizeForWeb(imagesInFolder: "Output/assets/images/blog/"))
...
])

which will use a quite good image transformation by Dave Newton.

If you want more control over the transformation you can use, for instance,

import MagickPublishPlugin
...
try DeliciousRecipes().publish(using: [
.installPlugin(
...
    .magick(arguments: [
                "mogrify",
                "-thumbnail",
                "400",
            ], 
            imagesFolder: "Output/assets/images/blog/")
)
...
])

You can also run the command on a single file:

import MagickPublishPlugin
...
try DeliciousRecipes().publish(using: [
.installPlugin(
...
    .magick(arguments: [
                "mogrify",
                "-thumbnail",
                "400",
                ], 
                imageFile: "Output/assets/images/blog/my-cat-eating-a-burrito.jpg")
)
...
])

You probably want to run this step after .copyResources().

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

Last updated: Thu Mar 28 2024 11:44:35 GMT-0900 (Hawaii-Aleutian Daylight Time)