Class: JXL::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/jxl/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:, channels:, metadata:, frames: [], icc_profile: nil) ⇒ Image

rubocop:disable Metrics/ParameterLists



19
20
21
22
23
24
25
26
# File 'lib/jxl/image.rb', line 19

def initialize(width:, height:, channels:, metadata:, frames: [], icc_profile: nil) # rubocop:disable Metrics/ParameterLists
  @width = width
  @height = height
  @channels = channels
  @metadata = 
  @frames = frames
  @icc_profile = icc_profile
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



17
18
19
# File 'lib/jxl/image.rb', line 17

def channels
  @channels
end

#framesObject (readonly)

Returns the value of attribute frames.



17
18
19
# File 'lib/jxl/image.rb', line 17

def frames
  @frames
end

#heightObject (readonly)

Returns the value of attribute height.



17
18
19
# File 'lib/jxl/image.rb', line 17

def height
  @height
end

#icc_profileObject (readonly)

Returns the value of attribute icc_profile.



17
18
19
# File 'lib/jxl/image.rb', line 17

def icc_profile
  @icc_profile
end

#metadataObject (readonly)

Returns the value of attribute metadata.



17
18
19
# File 'lib/jxl/image.rb', line 17

def 
  @metadata
end

#widthObject (readonly)

Returns the value of attribute width.



17
18
19
# File 'lib/jxl/image.rb', line 17

def width
  @width
end

Instance Method Details

#color_encodingObject



36
# File 'lib/jxl/image.rb', line 36

def color_encoding = .colour_encoding

#extra_channelsObject



35
# File 'lib/jxl/image.rb', line 35

def extra_channels = channels.drop(num_color_channels)

#num_color_channelsObject



34
# File 'lib/jxl/image.rb', line 34

def num_color_channels = channels.length - .extra_channels.length

#to_floatObject

Returns little-endian interleaved RGBA pixels with binary32 samples.



47
# File 'lib/jxl/image.rb', line 47

def to_float = interleaved_rgba.pack("e*")

#to_rgba16Object

Returns little-endian interleaved RGBA pixels with 16-bit unsigned samples.



42
43
44
# File 'lib/jxl/image.rb', line 42

def to_rgba16
  interleaved_rgba.map { |value| (Num.clamp(value, 0.0, 1.0) * 65_535).round }.pack("v*")
end

#to_rgba8Object

Returns interleaved RGBA pixels with 8-bit unsigned samples.



39
# File 'lib/jxl/image.rb', line 39

def to_rgba8 = interleaved_rgba.map { |value| (Num.clamp(value, 0.0, 1.0) * 255).round }.pack("C*")

#with(**changes) ⇒ Object



28
29
30
31
32
# File 'lib/jxl/image.rb', line 28

def with(**changes)
  self.class.new(width: changes.fetch(:width, width), height: changes.fetch(:height, height),
                 channels: changes.fetch(:channels, channels), metadata: changes.fetch(:metadata, ),
                 frames: changes.fetch(:frames, frames), icc_profile: changes.fetch(:icc_profile, icc_profile))
end