Module: Magick

Defined in:
lib/rvg/rvg.rb,
lib/RMagick.rb,
lib/rvg/misc.rb,
lib/rvg/misc.rb,
lib/rvg/misc.rb,
lib/rvg/text.rb,
lib/rvg/paint.rb,
lib/rvg/units.rb,
lib/rvg/clippath.rb,
lib/rvg/pathdata.rb,
lib/rvg/stylable.rb,
lib/rvg/container.rb,
lib/rvg/deep_equal.rb,
lib/rvg/describable.rb,
lib/rvg/stretchable.rb,
lib/rvg/embellishable.rb,
lib/rvg/transformable.rb,
ext/RMagick/rmmain.c

Overview

– $Id: transformable.rb,v 1.4 2008/02/24 18:26:37 rmagick Exp $ Copyright © 2008 Timothy P. Hunter ++

Defined Under Namespace

Modules: IPTC Classes: DestroyedImageError, Draw, Enum, Geometry, GeometryValue, GradientFill, HatchFill, Image, ImageList, ImageMagickError, OptionalMethodArguments, Pixel, RVG, TextureFill

Constant Summary collapse

PercentGeometry =
GeometryValue.new(:PercentGeometry, 1).freeze
AspectGeometry =
GeometryValue.new(:AspectGeometry, 2).freeze
LessGeometry =
GeometryValue.new(:LessGeometry, 3).freeze
GreaterGeometry =
GeometryValue.new(:GreaterGeometry, 4).freeze
AreaGeometry =
GeometryValue.new(:AreaGeometry, 5).freeze
MinimumGeometry =
GeometryValue.new(:MinimumGeometry, 6).freeze
AlphaChannel =
_enum
DefaultChannels =
_enum
HueChannel =
_enum
LuminosityChannel =
_enum
SaturationChannel =
_enum
AffineMatrix =
Class_AffineMatrix
Primary =
Class_Primary
Chromaticity =
Class_Chromaticity
Color =
Class_Color
Point =
Class_Point
Rectangle =
Class_Rectangle
Segment =
Class_Segment
Font =
Class_Font
TypeMetric =
Class_TypeMetric
Magick_version =
str
Version =
str
Long_version =
str
@@formats =
nil

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.trace_proc=(value) ⇒ Object (writeonly)

Sets the attribute trace_proc

Parameters:

  • value

    the value to set the attribute trace_proc to.



27
28
29
# File 'lib/RMagick.rb', line 27

def trace_proc=(value)
  @trace_proc = value
end

Class Method Details

.colorsObject

Method: Magick::colors [ { |colorinfo| } ] Purpose: If called with the optional block, iterates over the colors,

otherwise returns an array of Magick::Color objects

Notes: There are 3 implementations



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'ext/RMagick/rmmain.c', line 32

VALUE
Magick_colors(VALUE class)
{
    const ColorInfo **color_info_list;
    unsigned long number_colors, x;
    volatile VALUE ary;
    ExceptionInfo exception;

    GetExceptionInfo(&exception);

    color_info_list = GetColorInfoList("*", &number_colors, &exception);
    CHECK_EXCEPTION()
    (void) DestroyExceptionInfo(&exception);


    if (rb_block_given_p())
    {
        for (x = 0; x < number_colors; x++)
        {
            (void) rb_yield(Color_from_ColorInfo(color_info_list[x]));
        }
        magick_free((void *)color_info_list);
        return class;
    }
    else
    {
        ary = rb_ary_new2((long) number_colors);
        for (x = 0; x < number_colors; x++)
        {
            (void) rb_ary_push(ary, Color_from_ColorInfo(color_info_list[x]));
        }

        magick_free((void *)color_info_list);
        return ary;
    }
}

.fontsObject

Method: Magick::fonts [ { |fontinfo| } ] Purpose: If called with the optional block, iterates over the fonts,

otherwise returns an array of Magick::Font objects


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'ext/RMagick/rmmain.c', line 75

VALUE
Magick_fonts(VALUE class)
{
    const TypeInfo **type_info;
    unsigned long number_types, x;
    volatile VALUE ary;
    ExceptionInfo exception;

    GetExceptionInfo(&exception);
    type_info = GetTypeInfoList("*", &number_types, &exception);
    CHECK_EXCEPTION()
    (void) DestroyExceptionInfo(&exception);

    if (rb_block_given_p())
    {
        for (x = 0; x < number_types; x++)
        {
            (void) rb_yield(Font_from_TypeInfo((const TypeInfo *)type_info[x]));
        }
        magick_free((void *)type_info);
        return class;
    }
    else
    {
        ary = rb_ary_new2((long)number_types);
        for (x = 0; x < number_types; x++)
        {
            (void) rb_ary_push(ary, Font_from_TypeInfo((const TypeInfo *)type_info[x]));
        }
        magick_free((void *)type_info);
        return ary;
    }

}

.formats(&block) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/RMagick.rb', line 16

def Magick.formats(&block)
    @@formats ||= Magick.init_formats
    if block_given?
        @@formats.each { |k,v| yield(k,v) }
        self
    else
        @@formats
    end
end

.init_formatsObject



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'ext/RMagick/rmmain.c', line 141

VALUE
Magick_init_formats(VALUE class)
{
    const MagickInfo **magick_info;
    unsigned long number_formats, x;
    volatile VALUE formats;
    ExceptionInfo exception;

    class = class;      // defeat "never referenced" message from icc
    formats = rb_hash_new();

    // IM 6.1.3 added an exception argument to GetMagickInfoList
    GetExceptionInfo(&exception);
    magick_info = GetMagickInfoList("*", &number_formats, &exception);
    CHECK_EXCEPTION()
    (void) DestroyExceptionInfo(&exception);


    for (x = 0; x < number_formats; x++)
    {
        (void) rb_hash_aset(formats
                            , rb_str_new2(magick_info[x]->name)
                            , MagickInfo_to_format((const MagickInfo *)magick_info[x]));
    }
    return formats;
}

.limit_resource(*args) ⇒ Object

Method: Magick.limit_resource(resource[, limit]) Purpose: Get/set resource limits. If a limit is specified the old limit

is set to the new value. Either way the current/new limit is returned.


174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'ext/RMagick/rmmain.c', line 174

static VALUE
Magick_limit_resource(int argc, VALUE *argv, VALUE class)
{
    volatile VALUE resource, limit;
    ResourceType res = UndefinedResource;
    char *str;
    ID id;
    unsigned long cur_limit;

    rb_scan_args(argc, argv, "11", &resource, &limit);

    switch (TYPE(resource))
    {
        case T_NIL:
            return class;

        case T_SYMBOL:
            id = (ID)SYM2ID(resource);
            if (id == rb_intern("area"))
            {
                res = AreaResource;
            }
            else if (id == rb_intern("memory"))
            {
                res = MemoryResource;
            }
            else if (id == rb_intern("map"))
            {
                res = MapResource;
            }
            else if (id == rb_intern("disk"))
            {
                res = DiskResource;
            }
            else if (id == rb_intern("file"))
            {
                res = FileResource;
            }
            else
            {
                rb_raise(rb_eArgError, "unknown resource: `:%s'", rb_id2name(id));
            }
            break;

        default:
            str = StringValuePtr(resource);
            if (*str == '\0')
            {
                return class;
            }
            else if (rm_strcasecmp("area", str) == 0)
            {
                res = AreaResource;
            }
            else if (rm_strcasecmp("memory", str) == 0)
            {
                res = MemoryResource;
            }
            else if (rm_strcasecmp("map", str) == 0)
            {
                res = MapResource;
            }
            else if (rm_strcasecmp("disk", str) == 0)
            {
                res = DiskResource;
            }
            else if (rm_strcasecmp("file", str) == 0)
            {
                res = FileResource;
            }
            else
            {
                rb_raise(rb_eArgError, "unknown resource: `%s'", str);
            }
            break;
    }

    cur_limit = GetMagickResourceLimit(res);

    if (argc > 1)
    {
        (void) SetMagickResourceLimit(res, (MagickSizeType)NUM2ULONG(limit));
    }

    return ULONG2NUM(cur_limit);
}

.set_cache_threshold(threshold) ⇒ Object

Method Magick.set_cache_threshold(megabytes) Purpose: sets the amount of free memory allocated for the

pixel cache.  Once this threshold is exceeded, all
subsequent pixels cache operations are to/from disk.

Notes: singleton method



269
270
271
272
273
274
275
276
# File 'ext/RMagick/rmmain.c', line 269

static VALUE
Magick_set_cache_threshold(VALUE class, VALUE threshold)
{
    unsigned long thrshld = NUM2ULONG(threshold);
    (void) SetMagickResourceLimit(MemoryResource, (MagickSizeType)thrshld);
    (void) SetMagickResourceLimit(MapResource, (MagickSizeType)(2*thrshld));
    return class;
}

.set_log_event_mask(*args) ⇒ Object

Method: Magick.set_log_event_mask(event,…) -> Magick Notes: “event” is one of “all”, “annotate”, “blob”, “cache”,

"coder", "configure", "deprecate", "locale", "none",
"render", "transform", "user", "x11". Multiple events
can be specified. Event names may be capitalized.


286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'ext/RMagick/rmmain.c', line 286

static VALUE
Magick_set_log_event_mask(int argc, VALUE *argv, VALUE class)
{
    int x;

    if (argc == 0)
    {
        rb_raise(rb_eArgError, "wrong number of arguments (at least 1 required)");
    }
    for (x = 0; x < argc; x++)
    {
        (void) SetLogEventMask(StringValuePtr(argv[x]));
    }
    return class;
}

.set_log_format(format) ⇒ Object

Method: Magick.set_log_format(format) -> Magick Notes: Format is a string containing one or more of:

%t  - current time
%r  - elapsed time
%u  - user time
%p  - pid
%m  - module (source file name)
%f  - function name
%l  - line number
%d  - event domain (one of the events listed above)
%e  - event name
Plus other characters, including \n, etc.


316
317
318
319
320
321
# File 'ext/RMagick/rmmain.c', line 316

static VALUE
Magick_set_log_format(VALUE class, VALUE format)
{
    SetLogFormat(StringValuePtr(format));
    return class;
}