module Magick

Table of Contents

module methods

module methods

colors

Magick.colors { |color| block } -> Magick
Magick.colors -> array

Description

Lists the named colors. If the optional block is present, calls the block once for each color, passing a Magick::Color object. Otherwise, returns an array of Magick::Color objects, one for each color.

The Magick::Color class is a Struct class with the following attributes:

Magick::Color attributes
Attribute Value
name The color name. For example, "red".
compliance A ComplianceType value such as X11Compliance.
color A Pixel object containing the RGB values.

Returns

If no block is associated with the call, returns an array of Magick::Color objects.

Example

This is a small sample of colors.miff, the complete image created by the example program.

Magick::colors example

Magick API

GetColorInfo

fonts

Magick.fonts { |font| block } -> Magick
Magick.fonts -> array

Description

Lists the fonts that ImageMagick knows about. If the optional block is present, calls the block once for each font, passing a Magick::Font object. Otherwise, returns an array of Magick::Font objects, one for each font.

The Magick::Font class is a Struct class with the following attributes:

Magick::Font attributes
Attribute Value
name The font name. For example, "Palatino-Roman".
description The font description. For example, "Palatino Roman".
family The font family. For example, "Palatino", "Helvetica", or "Courier".
style A StyleType value such as NormalStyle.
stretch A StretchType value such as NormalStretch.
weight The font weight, one of 100, 200, 300, 400, 500, 600, 700, 800, or 900.
encoding The font encoding, such as "AppleRoman". May be nil.
foundry The font foundry. "URW", for example. May be nil.
format If the font is a Type1 font, has the value "type1", otherwise nil.

Returns

If no block is associated with the call, returns an array of Magick::Font objects.

Example

fonts.rb

Magick API

GetFontInfo

formats

Magick.formats { |f,v| block } -> Magick
Magick.formats -> hash

Description

Describes the image formats supported by ImageMagick. If the optional block is present, calls the block once for each image format. The first argument, f, is the format name. The second argument, v, is the properties string described below.

Returns

A hash of image formats and their properties. Each key in the returned hash is the name of a supported image format. Each value is a string in the form "BRWA". The details are in this table:
Format property codes
Code Definition
B is "*" if the format has native blob support, and "-" otherwise.
R is "r" if ImageMagick can read the format, and "-" otherwise.
W is "w" if ImageMagick can write the format, and "-" otherwise.
A is "+" if the format supports multi-image files, and "-" otherwise.

Example

p Magick.formats »
   {"TIF"=>"*rw+",
   "H"=>"*rw-",
   "MNG"=>"*rw+",
   "NULL"=>"*rw-",
   ...
   "G"=>"*rw+",
   "GIF"=>"*rw+",
   "PDB"=>"*rw+"}

Magick API

GetMagickInfo

Note

ImageMagick depends on external programs for some formats. Depending on how ImageMagick was installed on your system, some formats may not be available. If you have questions, ask your system administrator.

limit_resource

Magick.limit_resource(resource_type [, limit]) -> old_limit

Description

Sets a limit to the amount of a resource, or gets the current limit for the resource. When the limit is reached, ImageMagick will fail in some fashion or take compensating actions if possible. The default limits vary according to the platform. See the ImageMagick documentation for the -limit option for more information.

Arguments

This method may be called with one or two arguments. The first argument identifies the resource. If specified, the second argument is the limit.
resource_type
One of the symbols :area, :disk, :file, :map, or :memory. You may use a string instead of a symbol.
limit
If present, the limit for the resource. This argument is always an integer number. If the resource_type is :file, the limit is the number of open files. If :memory or :map, the limit is measured megabytes. If :disk, the limit is measured in gigabytes. If the resource_type is :area the limit is the maximum width * height of an image in pixels that can reside in pixel cache memory. If this argument is omitted the limit is not changed.

Returns

The current resource limit. If a new limit is specified this is the limit before the change.

Notes

This method supercedes set_cache_threshold.

set_log_event_mask

Magick.set_log_event_mask(event_list)

Description

Specify which events to log.

Argument

A string composed of one or more of the following event types. If more than one event type is specified, separate the event types with commas.

All, Annotate, Blob, Cache, Coder, Configure, Deprecate, Draw, Exception, Locale, Module, None, Resource, Trace, Transform, User, Wand, X11

Example

Magick.set_log_event_mask("Module,Coder")

Magick API

SetLogEventMask

See also

set_log_format

Log configuration

Magick logging is configured with the log.xml file in Magick's config directory. See Resources in the ImageMagick documentation for more information.

Use this command to find out about the current log configuration.

convert -list log

set_log_format

Magick.set_log_format(format)

Description

Specify the event log format.

Argument

A fprintf-like format string composed of optional "normal" text (to which no meaning is assigned) and the following format characters:

%d
domain
%e
event
%f
function
%l
line
%m
module
%p
process ID
%r
read CPU time
%t
wall clock time
%u
user CPU time
%%
percent sign
\n
newline
\r
carriage return

trace_proc

Magick.trace_proc = proc

Description

If the Magick module attribute trace_proc is set to a Proc object, RMagick calls the proc whenever an image is created or destroyed. You can use this proc to keep track of which images your program has created and which have been destroyed.

Arguments

The proc should accept these four arguments:

which
A symbol that indicates which operation the proc is being called for. If the proc is called for an image creation, the value is :c. If called for an image destruction, the value is :d.
description
A string describing the image. This is the same string that would be returned by calling the image's inspect method.
id
A unique identifier for the image. This identifier is not the same as the object's object_id. No two images will have the same id at the same time. However, the id of an image that has been destroyed may be reused for a subsequent image.
method
The name of the method responsible for creating or destroying the image.

Notes

If called while Ruby is cleaning up after the program has finished, any methods the proc calls may not be executed.

Use the "user" option to add an additional identifying string to the image's description.