Method: Magick::Image#fx

Defined in:
ext/RMagick/rmimage.cpp

#fx(expression, channel = Magick::AllChannels) ⇒ Magick::Image #fx(expression, *channels) ⇒ Magick::Image

Apply fx on the image.

Overloads:

  • #fx(expression, channel = Magick::AllChannels) ⇒ Magick::Image

    Parameters:

    • expression (String)

      A mathematical expression

    • channel (Magick::ChannelType) (defaults to: Magick::AllChannels)

      a ChannelType arguments.

  • #fx(expression, *channels) ⇒ Magick::Image

    Parameters:

    • expression (String)

      A mathematical expression

    • *channels (Magick::ChannelType)

      one or more ChannelType arguments.

Returns:



7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
# File 'ext/RMagick/rmimage.cpp', line 7458

VALUE
Image_fx(int argc, VALUE *argv, VALUE self)
{
    Image *image, *new_image;
    char *expression;
    ChannelType channels;
    ExceptionInfo *exception;

    image = rm_check_destroyed(self);
    channels = extract_channels(&argc, argv);

    // There must be exactly 1 remaining argument.
    if (argc == 0)
    {
        rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)");
    }
    else if (argc > 1)
    {
        raise_ChannelType_error(argv[argc-1]);
    }

    expression = StringValueCStr(argv[0]);

    exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
    BEGIN_CHANNEL_MASK(image, channels);
    GVL_STRUCT_TYPE(FxImage) args = { image, expression, exception };
    new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FxImage), &args);
    CHANGE_RESULT_CHANNEL_MASK(new_image);
    END_CHANNEL_MASK(image);
#else
    GVL_STRUCT_TYPE(FxImageChannel) args = { image, channels, expression, exception };
    new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FxImageChannel), &args);
#endif
    rm_check_exception(exception, new_image, DestroyOnError);
    DestroyExceptionInfo(exception);

    return rm_image_new(new_image);
}