Method: Magick::Image#polaroid

Defined in:
ext/RMagick/rmimage.cpp

#polaroid(angle = -5.0) ⇒ Magick::Image #polaroid(angle = -5.0) {|opt| ... } ⇒ Magick::Image

Produce an image that looks like a Polaroid instant picture. If the image has a “Caption” property, the value is used as a caption.

The following annotate attributes control the label rendering: align, decorate, density, encoding, fill, font, font_family, font_stretch, font_style, font_weight, gravity, pointsize, stroke, stroke_width, text_antialias, undercolor.

Overloads:

  • #polaroid(angle = -5.0) ⇒ Magick::Image

    Parameters:

    • angle (Numeric) (defaults to: -5.0)

      The resulting image is rotated by this amount, measured in degrees.

  • #polaroid(angle = -5.0) {|opt| ... } ⇒ Magick::Image

    If present a block, optional arguments may be specified in a block associated with the method. These arguments control the shadow color and how the label is rendered. By default the shadow color is gray75. To specify a different shadow color, use options.shadow_color. To specify a different border color (that is, the color of the image border) use options.border_color. Both of these methods accept either a color name or a Pixel argument.

    Parameters:

    • angle (Numeric) (defaults to: -5.0)

      The resulting image is rotated by this amount, measured in degrees.

    Yields:

    • (opt)

    Yield Parameters:

Returns:



10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
# File 'ext/RMagick/rmimage.cpp', line 10826

VALUE
Image_polaroid(int argc, VALUE *argv, VALUE self)
{
    Image *image, *clone, *new_image;
    VALUE options;
    double angle = -5.0;
    Draw *draw;
    ExceptionInfo *exception;
#if defined(IMAGEMAGICK_7)
    const char *caption;
#endif

    image = rm_check_destroyed(self);

    switch (argc)
    {
        case 1:
            angle = NUM2DBL(argv[0]);
        case 0:
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
            break;
    }

    options = rm_polaroid_new();
    TypedData_Get_Struct(options, Draw, &rm_draw_data_type, draw);

    clone = rm_clone_image(image);
    clone->background_color = draw->shadow_color;
    clone->border_color = draw->info->border_color;

    exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
    caption = GetImageProperty(clone, "Caption", exception);
    GVL_STRUCT_TYPE(PolaroidImage) args = { clone, draw->info, caption, angle, image->interpolate, exception };
    new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PolaroidImage), &args);
#else
    GVL_STRUCT_TYPE(PolaroidImage) args = { clone, draw->info, angle, exception };
    new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PolaroidImage), &args);
#endif
    rm_check_exception(exception, clone, DestroyOnError);

    DestroyImage(clone);
    DestroyExceptionInfo(exception);

    RB_GC_GUARD(options);

    return rm_image_new(new_image);
}