Module: Vips::Process::Convert

Defined in:
lib/vips-process/convert.rb

Constant Summary collapse

ALLOWED_FORMATS =
[JPEG, PNG]

Instance Method Summary collapse

Instance Method Details

#convert(format, opts = {}) ⇒ Object

Converts an image to a different format

Parameters:

  • format

    String the format we’ll convert the file to (jpeg, png)

  • opts (defaults to: {})

    Hash options to be passed to converting function (ie, :interlace => true for png)

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'lib/vips-process/convert.rb', line 12

def convert(format, opts = {})
  format = format.to_s.downcase
  raise ArgumentError, "Format must be one of: #{ALLOWED_FORMATS.join(',')}" unless ALLOWED_FORMATS.include?(format)
  @_format = format
  @_format_opts = opts
  self
end