Module: Gsplat::IO::Image

Defined in:
lib/gsplat/io/image.rb

Overview

RGB image input/output with vips-first optional backends.

Constant Summary collapse

BACKENDS =

Optional image backend implementations in preference order.

{
  vips: VipsImageBackend,
  chunky_png: ChunkyPngImageBackend
}.freeze

Class Method Summary collapse

Class Method Details

.available_backendsArray<Symbol>

Returns image codecs currently loadable in this process.

Returns:

  • (Array<Symbol>)

    subset of :vips and :chunky_png



31
32
33
# File 'lib/gsplat/io/image.rb', line 31

def available_backends
  BACKENDS.filter_map { |name, implementation| name if implementation.available? }
end

.read(path, backend: :auto) ⇒ Object

Reads an image as float32 [H,W,3] in the range 0..1.



18
19
20
# File 'lib/gsplat/io/image.rb', line 18

def read(path, backend: :auto)
  resolve_backend(backend).read(path)
end

.write(path, array, backend: :auto) ⇒ Object

Writes a float [H,W,3] image, clamping values to 0..1.



23
24
25
26
# File 'lib/gsplat/io/image.rb', line 23

def write(path, array, backend: :auto)
  validate_array!(array)
  resolve_backend(backend).write(path, array)
end