Class: JXL::Image
- Inherits:
-
Object
- Object
- JXL::Image
- Defined in:
- lib/jxl/image.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#icc_profile ⇒ Object
readonly
Returns the value of attribute icc_profile.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #color_encoding ⇒ Object
- #extra_channels ⇒ Object
-
#initialize(width:, height:, channels:, metadata:, frames: [], icc_profile: nil) ⇒ Image
constructor
rubocop:disable Metrics/ParameterLists.
- #num_color_channels ⇒ Object
-
#to_float ⇒ Object
Returns little-endian interleaved RGBA pixels with binary32 samples.
-
#to_rgba16 ⇒ Object
Returns little-endian interleaved RGBA pixels with 16-bit unsigned samples.
-
#to_rgba8 ⇒ Object
Returns interleaved RGBA pixels with 8-bit unsigned samples.
- #with(**changes) ⇒ Object
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
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
17 18 19 |
# File 'lib/jxl/image.rb', line 17 def channels @channels end |
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
17 18 19 |
# File 'lib/jxl/image.rb', line 17 def frames @frames end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
17 18 19 |
# File 'lib/jxl/image.rb', line 17 def height @height end |
#icc_profile ⇒ Object (readonly)
Returns the value of attribute icc_profile.
17 18 19 |
# File 'lib/jxl/image.rb', line 17 def icc_profile @icc_profile end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
17 18 19 |
# File 'lib/jxl/image.rb', line 17 def @metadata end |
#width ⇒ Object (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_encoding ⇒ Object
36 |
# File 'lib/jxl/image.rb', line 36 def color_encoding = .colour_encoding |
#extra_channels ⇒ Object
35 |
# File 'lib/jxl/image.rb', line 35 def extra_channels = channels.drop(num_color_channels) |
#num_color_channels ⇒ Object
34 |
# File 'lib/jxl/image.rb', line 34 def num_color_channels = channels.length - .extra_channels.length |
#to_float ⇒ Object
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_rgba16 ⇒ Object
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_rgba8 ⇒ Object
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 |