class ChunkyPNG::Chunk::Physical
The Physical
(pHYs) chunk specifies the intended pixel size or aspect ratio for display of the image.
Constants
- INCHES_PER_METER
Attributes
Public Class Methods
Source
# File lib/chunky_png/chunk.rb 365 def initialize(ppux, ppuy, unit = :unknown) 366 raise ArgumentError, "unit must be either :meters or :unknown" unless [:meters, :unknown].member?(unit) 367 super("pHYs") 368 @ppux, @ppuy, @unit = ppux, ppuy, unit 369 end
Calls superclass method
ChunkyPNG::Chunk::Base::new
Source
# File lib/chunky_png/chunk.rb 381 def self.read(type, content) 382 ppux, ppuy, unit = content.unpack("NNC") 383 unit = unit == 1 ? :meters : :unknown 384 new(ppux, ppuy, unit) 385 end
Public Instance Methods
Source
# File lib/chunky_png/chunk.rb 389 def content 390 [ppux, ppuy, unit == :meters ? 1 : 0].pack("NNC") 391 end
Assembles the content to write to the stream for this chunk. @return [String] The binary content that should be written to the datastream.
Source
# File lib/chunky_png/chunk.rb 371 def dpix 372 raise ChunkyPNG::UnitsUnknown, "the PNG specifies its physical aspect ratio, but does not specify the units of its pixels' physical dimensions" unless unit == :meters 373 ppux * INCHES_PER_METER 374 end
Source
# File lib/chunky_png/chunk.rb 376 def dpiy 377 raise ChunkyPNG::UnitsUnknown, "the PNG specifies its physical aspect ratio, but does not specify the units of its pixels' physical dimensions" unless unit == :meters 378 ppuy * INCHES_PER_METER 379 end