Sha256: 31a168e16de0edbe3aa716964683bc14752275d731e7d816e3c6c2178e8eba54
Contents?: true
Size: 986 Bytes
Versions: 15
Compression:
Stored size: 986 Bytes
Contents
module ChunkyPNG # Image class # class Image < Canvas METADATA_COMPRESSION_TRESHOLD = 300 attr_accessor :metadata def initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT, metadata = {}) super(width, height, initial) @metadata = metadata @metadata_compression_treshhold = 300 end def initialize_copy(other) super(other) @metdata = other.metadata end def metadata_chunks metadata.map do |key, value| if value.length >= METADATA_COMPRESSION_TRESHOLD ChunkyPNG::Chunk::CompressedText.new(key, value) else ChunkyPNG::Chunk::Text.new(key, value) end end end def to_datastream(constraints = {}) ds = super(constraints) ds.other_chunks += metadata_chunks return ds end def self.from_datastream(ds) image = super(ds) image.metadata = ds.metadata return image end end end
Version data entries
15 entries across 15 versions & 1 rubygems