Sha256: 712cadd1d8ced542cfa72a0f6227837fa241a061e8c80d576cfc7bf23d7a674f
Contents?: true
Size: 661 Bytes
Versions: 22
Compression:
Stored size: 661 Bytes
Contents
class FormatParser::PSDParser include FormatParser::IOUtils PSD_HEADER = [0x38, 0x42, 0x50, 0x53] def likely_match?(filename) filename =~ /\.psd$/i # Maybe also PSB at some point end 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 new, natures: :image, formats: :psd end
Version data entries
22 entries across 22 versions & 1 rubygems