Method: Magick::Image.from_blob

Defined in:
ext/RMagick/rmimage.cpp

.from_blob(blob) ⇒ Array<Magick::Image> .from_blob(blob) {|Magick::Image::Info| ... } ⇒ Array<Magick::Image>

Convert direct to memory image formats from string data.

Overloads:

  • .from_blob(blob) ⇒ Array<Magick::Image>

    Parameters:

    • blob (String)

      the blob data

  • .from_blob(blob) {|Magick::Image::Info| ... } ⇒ Array<Magick::Image>

    This yields Info to block with its object’s scope.

    Parameters:

    • blob (String)

      the blob data

    Yields:

Returns:

See Also:



7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
# File 'ext/RMagick/rmimage.cpp', line 7281

VALUE
Image_from_blob(VALUE klass ATTRIBUTE_UNUSED, VALUE blob_arg)
{
    Image *images;
    Info *info;
    VALUE info_obj;
    ExceptionInfo *exception;
    void *blob;
    size_t length;

    blob = (void *) rm_str2cstr(blob_arg, &length);

    // Get a new Info object - run the parm block if supplied
    info_obj = rm_info_new();
    TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);

    exception = AcquireExceptionInfo();
    GVL_STRUCT_TYPE(BlobToImage) args = { info,  blob, (size_t)length, exception };
    images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
    rm_check_exception(exception, images, DestroyOnError);

    DestroyExceptionInfo(exception);

    rm_ensure_result(images);
    rm_set_user_artifact(images, info);

    RB_GC_GUARD(info_obj);

    return array_from_images(images);
}