ExOptimizer.Optimizer behaviour (ExOptimizer v0.1.1) View Source

Behaviour for creating ExOptimizer optimizers.

The current list of optimizers bundled with ExOptimizer are the following:

Example

defmodule ExOptimizer.Optimizers.Custom do
  @behaviour ExOptimizer.Optimizer

  def binary_name(), do: "some_command"

  def can_handle(%Image{path: path, ext: ext, mime: mime} = _image), do: mime == "image/something"

  def extra_args(%Image{path: path} = _image), do: ["-o #{path}"]

  def options(), do: ["--force", "--produce 'best'"]
end

Link to this section Summary

Link to this section Callbacks

Specs

binary_name() :: String.t()

Specs

can_handle(ExOptimizer.Image.t()) :: boolean()

Specs

extra_args(ExOptimizer.Image.t()) :: [String.t()]

Specs

options() :: [String.t()]