class FormatParser::PSDParser
Constants
- PSD_HEADER
- PSD_MIME_TYPE
Public Instance Methods
call(io)
click to toggle source
# File lib/parsers/psd_parser.rb, line 11 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, content_type: PSD_MIME_TYPE, ) end
likely_match?(filename)
click to toggle source
# File lib/parsers/psd_parser.rb, line 7 def likely_match?(filename) filename =~ /\.psd$/i # Maybe also PSB at some point end