Method: Vips::Image#write_to_file

Defined in:
lib/vips8/image.rb

#write_to_file(name, opts = {}) ⇒ Object

Write this image to a file. Save options may be encoded in the filename or given as a hash. For example:

image.write_to_file "fred.jpg[Q=90]"

or equivalently:

image.write_to_file "fred.jpg", :Q => 90

The full set of save options depend on the selected saver. Try something like:

$ vips jpegsave

to see all the available options.

Parameters:

  • opts (Hash) (defaults to: {})

    set of options

  • name (String)

    filename to write to

Options Hash (opts):

  • :strip (Boolean) — default: false

    Strip all metadata from image

  • :background (Array<Float>) — default: 0

    Background colour to flatten alpha against, if necessary

[View source]

566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/vips8/image.rb', line 566

def write_to_file(name, opts = {})
    filename = Vips::filename_get_filename name
    option_string = Vips::filename_get_options name
    saver = Vips::Foreign.find_save filename
    if saver == nil
        raise Vips::Error, "No known saver for '#{filename}'."
    end

    Vips::call_base saver, self, option_string, [filename, opts]

    write_gc
end