Module: MiniMagick::Configuration

Included in:
MiniMagick
Defined in:
lib/mini_magick/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cliSymbol

Set whether you want to use [ImageMagick](www.imagemagick.org) or [GraphicsMagick](www.graphicsmagick.org).

Returns:

  • (Symbol)

    ‘:imagemagick` or `:minimagick`



12
13
14
# File 'lib/mini_magick/configuration.rb', line 12

def cli
  @cli
end

#cli_pathString

If you don’t have the CLI tools in your PATH, you can set the path to the executables.

Returns:

  • (String)


22
23
24
# File 'lib/mini_magick/configuration.rb', line 22

def cli_path
  @cli_path
end

#debugBoolean

When set to ‘true`, it outputs each command to STDOUT in their shell version.

Returns:

  • (Boolean)


39
40
41
# File 'lib/mini_magick/configuration.rb', line 39

def debug
  @debug
end

#loggerLogger

Logger for #debug, default is ‘MiniMagick::Logger.new(STDOUT)`, but you can override it, for example if you want the logs to be written to a file.

Returns:



47
48
49
# File 'lib/mini_magick/configuration.rb', line 47

def logger
  @logger
end

#processorObject



14
15
16
# File 'lib/mini_magick/configuration.rb', line 14

def processor
  @processor
end

#processor_pathObject



24
25
26
# File 'lib/mini_magick/configuration.rb', line 24

def processor_path
  @processor_path
end

#shell_apiString

Instructs MiniMagick how to execute the shell commands. Available APIs are “open3” (default) and “posix-spawn” (requires the “posix-spawn” gem).

Returns:

  • (String)


82
83
84
# File 'lib/mini_magick/configuration.rb', line 82

def shell_api
  @shell_api
end

#timeoutInteger

If you don’t want commands to take too long, you can set a timeout (in seconds).

Returns:

  • (Integer)


32
33
34
# File 'lib/mini_magick/configuration.rb', line 32

def timeout
  @timeout
end

#validate_on_createBoolean

If set to ‘true`, it will `identify` every newly created image, and raise `MiniMagick::Invalid` if the image is not valid. Useful for validating user input, although it adds a bit of overhead. Defaults to `true`.

Returns:

  • (Boolean)


56
57
58
# File 'lib/mini_magick/configuration.rb', line 56

def validate_on_create
  @validate_on_create
end

#validate_on_writeBoolean

If set to ‘true`, it will `identify` every image that gets written (with Image#write), and raise `MiniMagick::Invalid` if the image is not valid. Useful for validating that processing was sucessful, although it adds a bit of overhead. Defaults to `true`.

Returns:

  • (Boolean)


65
66
67
# File 'lib/mini_magick/configuration.rb', line 65

def validate_on_write
  @validate_on_write
end

#whinyBoolean

If set to ‘false`, it will not raise errors when ImageMagick returns status code different than 0. Defaults to `true`.

Returns:

  • (Boolean)


73
74
75
# File 'lib/mini_magick/configuration.rb', line 73

def whiny
  @whiny
end

Class Method Details

.extended(base) ⇒ Object



84
85
86
87
88
89
# File 'lib/mini_magick/configuration.rb', line 84

def self.extended(base)
  base.validate_on_create = true
  base.validate_on_write = true
  base.whiny = true
  base.shell_api = "open3"
end

Instance Method Details

#configure {|self| ... } ⇒ Object

Examples:

MiniMagick.configure do |config|
  config.cli = :graphicsmagick
  config.timeout = 5
end

Yields:

  • (self)


99
100
101
# File 'lib/mini_magick/configuration.rb', line 99

def configure
  yield self
end