Method: Vips::Image#set_value

Defined in:
lib/vips8/image.rb

#set_value(name, value) ⇒ Object

Set a metadata item on an image. Ruby types are automatically transformed into the matching GValue, if possible.

For example, you can use this to set an image's ICC profile:

x = y.set_value "icc-profile-data", profile

where profile is an ICC profile held as a binary string object.

Parameters:

  • name (String)

    Metadata field to set

  • value (Object)

    Value to set

See Also:

[View source]

700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
# File 'lib/vips8/image.rb', line 700

def set_value(name, value)
    gtype = get_typeof name
    if gtype != 0
        # array-ize
        value = Argument::arrayize gtype, value

        # blob-ize
        if gtype.type_is_a? GLib::Type["VipsBlob"]
            if not value.is_a? Vips::Blob
                value = Vips::Blob.copy value
            end
        end

        # image-ize
        if gtype.type_is_a? GLib::Type["VipsImage"]
            if not value.is_a? Vips::Image
                value = imageize match_image, value
            end
        end

    end

    set name, value
end