Class: Vips::Target

Inherits:
Connection show all
Defined in:
lib/vips/target.rb

Overview

A target. For example:

target = Vips::Target.new_to_file('k2.jpg')
image.write_to_target(target, '.jpg')

Direct Known Subclasses

TargetCustom

Defined Under Namespace

Modules: TargetLayout Classes: ManagedStruct, Struct

Instance Attribute Summary

Attributes inherited from GObject::GObject

#ptr, #references

Class Method Summary collapse

Methods inherited from Connection

#filename, #nick

Methods inherited from Object

#get, #get_pspec, #get_typeof, #get_typeof_error, print_all, #set, #signal_connect

Methods inherited from GObject::GObject

#ffi_managed_struct, ffi_managed_struct, #ffi_struct, ffi_struct, #initialize

Constructor Details

This class inherits a constructor from GObject::GObject

Class Method Details

.new_to_descriptor(descriptor) ⇒ Target

Create a new target to a file descriptor. File descriptors are small integers, for example 1 is stdout.

Pass targets to Image#write_to_target to write images to them.

Parameters:

  • descriptor (Integer)

    the file descriptor

Returns:

  • (Target)

    the new Vips::Target

Raises:



49
50
51
52
53
54
# File 'lib/vips/target.rb', line 49

def self.new_to_descriptor(descriptor)
  ptr = Vips.vips_target_new_to_descriptor descriptor
  raise Vips::Error if ptr.null?

  Vips::Target.new ptr
end

.new_to_file(filename) ⇒ Target

Create a new target to a file name.

Pass targets to Image#write_to_target to write images to them.

Parameters:

  • filename (String)

    the name of the file

Returns:

  • (Target)

    the new Vips::Target

Raises:



63
64
65
66
67
68
69
# File 'lib/vips/target.rb', line 63

def self.new_to_file(filename)
  raise Vips::Error, "filename is nil" if filename.nil?
  ptr = Vips.vips_target_new_to_file filename
  raise Vips::Error if ptr.null?

  Vips::Target.new ptr
end

.new_to_memoryTarget

Create a new target to an area of memory.

Pass targets to Image#write_to_target to write images to them.

Once the image has been written, use Object#get("blob") to read out the data.

Returns:

  • (Target)

    the new Vips::Target



80
81
82
83
84
# File 'lib/vips/target.rb', line 80

def self.new_to_memory
  ptr = Vips.vips_target_new_to_memory

  Vips::Target.new ptr
end