Method: Magick::Image#format

Defined in:
ext/RMagick/rmimage.cpp

#formatString?

Return the image encoding format. For example, “GIF” or “PNG”.

Returns:

  • (String, nil)

    the encoding format



7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
# File 'ext/RMagick/rmimage.cpp', line 7142

VALUE
Image_format(VALUE self)
{
    Image *image;
    const MagickInfo *magick_info;
    ExceptionInfo *exception;

    image = rm_check_destroyed(self);

    if (*image->magick)
    {
        // Deliberately ignore the exception info!
        exception = AcquireExceptionInfo();
        magick_info = GetMagickInfo(image->magick, exception);
        DestroyExceptionInfo(exception);
        return magick_info ? rb_str_new2(magick_info->name) : Qnil;
    }

    return Qnil;
}