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
338 def initialize(ppux, ppuy, unit = :unknown)
339   raise ArgumentError, "unit must be either :meters or :unknown" unless [:meters, :unknown].member?(unit)
340   super("pHYs")
341   @ppux, @ppuy, @unit = ppux, ppuy, unit
342 end
read(type, content) click to toggle source
    # File lib/chunky_png/chunk.rb
354 def self.read(type, content)
355   ppux, ppuy, unit = content.unpack("NNC")
356   unit = unit == 1 ? :meters : :unknown
357   new(ppux, ppuy, unit)
358 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
362 def content
363   [ppux, ppuy, unit == :meters ? 1 : 0].pack("NNC")
364 end
dpix() click to toggle source
    # File lib/chunky_png/chunk.rb
344 def dpix
345   raise ChunkyPNG::UnitsUnknown, "the PNG specifies its physical aspect ratio, but does not specify the units of its pixels' physical dimensions" unless unit == :meters
346   ppux * INCHES_PER_METER
347 end
dpiy() click to toggle source
    # File lib/chunky_png/chunk.rb
349 def dpiy
350   raise ChunkyPNG::UnitsUnknown, "the PNG specifies its physical aspect ratio, but does not specify the units of its pixels' physical dimensions" unless unit == :meters
351   ppuy * INCHES_PER_METER
352 end