Sha256: 7ec9af40e21a7b341b74acc813675cb4b0576810009e15ca299d226d0928f7a7
Contents?: true
Size: 608 Bytes
Versions: 1
Compression:
Stored size: 608 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.3.0 | lib/parsers/psd_parser.rb |