Sha256: 2a66a4bbf5a11b187dcd764d81e52ee208ce5ab484fa5ab754f4ff6b6290f026
Contents?: true
Size: 740 Bytes
Versions: 35
Compression:
Stored size: 740 Bytes
Contents
class FormatParser::PSDParser include FormatParser::IOUtils PSD_HEADER = [0x38, 0x42, 0x50, 0x53] PSD_MIME_TYPE = 'application/x-photoshop' 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, content_type: PSD_MIME_TYPE, ) end FormatParser.register_parser new, natures: :image, formats: :psd end
Version data entries
35 entries across 35 versions & 1 rubygems