Module: ZIMG

Defined in:
lib/zimg/bmp.rb,
lib/zimg.rb,
lib/zimg/cli.rb,
lib/zimg/png.rb,
lib/zimg/jpeg.rb,
lib/zimg/chunk.rb,
lib/zimg/color.rb,
lib/zimg/image.rb,
lib/zimg/pixels.rb,
lib/zimg/version.rb,
lib/zimg/bmp/color.rb,
lib/zimg/jpeg/idct.rb,
lib/zimg/bmp/chunks.rb,
lib/zimg/png/chunks.rb,
lib/zimg/jpeg/chunks.rb,
lib/zimg/jpeg/decoder.rb,
lib/zimg/jpeg/huffman.rb,
lib/zimg/png/metadata.rb,
lib/zimg/png/scanline.rb,
lib/zimg/jpeg/lossless.rb,
lib/zimg/jpeg/scanline.rb,
lib/zimg/jpeg/upsample.rb,
lib/zimg/jpeg/colorspace.rb,
lib/zimg/png/text_chunks.rb,
lib/zimg/png/adam7_decoder.rb,
lib/zimg/png/scanline_mixins.rb

Overview

Defined Under Namespace

Modules: BMP, DeepCopyable, JPEG, PNG Classes: ArgumentError, CLI, Chunk, Color, Error, Image, NotSupported, Pixels

Constant Summary collapse

VERSION =
"0.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.magicsObject (readonly)

Returns the value of attribute magics.



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

def magics
  @magics
end

Class Method Details

.from_rgb(data, width:, height:) ⇒ Object



35
36
37
# File 'lib/zimg.rb', line 35

def from_rgb(data, width:, height:)
  PNG.from_rgb(data, width: width, height: height)
end

.from_rgba(data, width:, height:) ⇒ Object



39
40
41
# File 'lib/zimg.rb', line 39

def from_rgba(data, width:, height:)
  PNG.from_rgba(data, width: width, height: height)
end

.load(fname, h = {}) ⇒ Object

load image from file



29
30
31
32
33
# File 'lib/zimg.rb', line 29

def load(fname, h = {})
  File.open(fname, "rb") do |f|
    Image.new(f, h)
  end
end

.register_format!(fmt) ⇒ Object



23
24
25
26
# File 'lib/zimg.rb', line 23

def register_format!(fmt)
  m = const_get(fmt.to_s.upcase)
  @magics[m.const_get("MAGIC")] = fmt
end

.supported_formatsObject



19
20
21
# File 'lib/zimg.rb', line 19

def supported_formats
  magics.values.uniq
end