Method: Magick::Image#frame

Defined in:
ext/RMagick/rmimage.cpp

#frame(width = self.columns+25*2, height = self.rows+25*2, x = 25, y = 25, inner_bevel = 6, outer_bevel = 6, color = self.matte_color) ⇒ Magick::Image

Add a simulated three-dimensional border around the image.

Returns a new image.

Parameters:

  • width (Numeric) (defaults to: self.columns+25*2)

    The width of the left and right sides.

  • height (Numeric) (defaults to: self.rows+25*2)

    The height of the top and bottom sides.

  • x (Numeric) (defaults to: 25)

    The offset of the image from the upper-left outside corner of the border.

  • y (Numeric) (defaults to: 25)

    The offset of the image from the upper-left outside corner of the border.

  • inner_bevel (Numeric) (defaults to: 6)

    The width of the inner shadows of the border.

  • outer_bevel (Numeric) (defaults to: 6)

    The width of the outer shadows of the border.

  • color (Magick::Pixel, String) (defaults to: self.matte_color)

    The border color.

Returns:



7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
# File 'ext/RMagick/rmimage.cpp', line 7212

VALUE
Image_frame(int argc, VALUE *argv, VALUE self)
{
    Image *image, *new_image;
    ExceptionInfo *exception;
    FrameInfo frame_info;

    image = rm_check_destroyed(self);

    frame_info.width = image->columns + 50;
    frame_info.height = image->rows + 50;
    frame_info.x = 25;
    frame_info.y = 25;
    frame_info.inner_bevel = 6;
    frame_info.outer_bevel = 6;

    switch (argc)
    {
        case 7:
            Color_to_PixelColor(&image->matte_color, argv[6]);
        case 6:
            frame_info.outer_bevel = NUM2LONG(argv[5]);
        case 5:
            frame_info.inner_bevel = NUM2LONG(argv[4]);
        case 4:
            frame_info.y = NUM2LONG(argv[3]);
        case 3:
            frame_info.x = NUM2LONG(argv[2]);
        case 2:
            frame_info.height = image->rows + 2*NUM2LONG(argv[1]);
        case 1:
            frame_info.width = image->columns + 2*NUM2LONG(argv[0]);
        case 0:
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 7)", argc);
            break;
    }

    exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
    GVL_STRUCT_TYPE(FrameImage) args = { image, &frame_info, image->compose, exception };
#else
    GVL_STRUCT_TYPE(FrameImage) args = { image, &frame_info, exception };
#endif
    new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FrameImage), &args);
    rm_check_exception(exception, new_image, DestroyOnError);
    DestroyExceptionInfo(exception);

    return rm_image_new(new_image);
}