class ChunkyPNG::Chunk::Physical

The Physical (pHYs) chunk specifies the intended pixel size or aspect ratio for display of the image.

www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.pHYs

Constants

INCHES_PER_METER

Attributes

ppux[RW]
ppuy[RW]
unit[RW]

Public Class Methods

new(ppux, ppuy, unit = :unknown) click to toggle source
Calls superclass method ChunkyPNG::Chunk::Base::new
    # File lib/chunky_png/chunk.rb
329 def initialize(ppux, ppuy, unit = :unknown)
330   raise ArgumentError, 'unit must be either :meters or :unknown' unless [:meters, :unknown].member?(unit)
331   super('pHYs')
332   @ppux, @ppuy, @unit = ppux, ppuy, unit
333 end
read(type, content) click to toggle source
    # File lib/chunky_png/chunk.rb
345 def self.read(type, content)
346   ppux, ppuy, unit = content.unpack('NNC')
347   unit = unit == 1 ? :meters : :unknown
348   new(ppux, ppuy, unit)
349 end

Public Instance Methods

content() click to toggle source

Assembles the content to write to the stream for this chunk. @return [String] The binary content that should be written to the datastream.

    # File lib/chunky_png/chunk.rb
353 def content
354   [ppux, ppuy, unit == :meters ? 1 : 0].pack('NNC')
355 end
dpix() click to toggle source
    # File lib/chunky_png/chunk.rb
335 def dpix
336   raise ChunkyPNG::UnitsUnknown, 'the PNG specifies its physical aspect ratio, but does not specify the units of its pixels\' physical dimensions' unless unit == :meters
337   ppux * INCHES_PER_METER
338 end
dpiy() click to toggle source
    # File lib/chunky_png/chunk.rb
340 def dpiy
341   raise ChunkyPNG::UnitsUnknown, 'the PNG specifies its physical aspect ratio, but does not specify the units of its pixels\' physical dimensions' unless unit == :meters
342   ppuy * INCHES_PER_METER
343 end