Sha256: b3d1293331c190e9cbf5ea903db00a74b171303e58e4729b06d5b04c73ddb6cd
Contents?: true
Size: 607 Bytes
Versions: 1
Compression:
Stored size: 607 Bytes
Contents
class FormatParser::PSDParser include FormatParser::IOUtils include FormatParser::DSL PSD_HEADER = [0x38, 0x42, 0x50, 0x53] natures :image formats :psd def call(io) io = FormatParser::IOConstraint.new(io) magic_bytes = safe_read(io, 4).unpack("C4") return unless magic_bytes == PSD_HEADER # We can be reasonably certain this is a PSD so we grab the height # and width bytes w,h = safe_read(io, 22).unpack("x10N2") FormatParser::Image.new( format: :psd, width_px: w, height_px: h, ) end FormatParser.register_parser_constructor self end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
format_parser-0.2.0 | lib/parsers/psd_parser.rb |