Sha256: 513850c90c84a7f387a5a1fc6852b055741385398225d2da4277a8b203f073b7

Contents?: true

Size: 568 Bytes

Versions: 32

Compression:

Stored size: 568 Bytes

Contents

class FormatParser::PSDParser
  include FormatParser::IOUtils

  PSD_HEADER = [0x38, 0x42, 0x50, 0x53]

  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 self, natures: :image, formats: :psd
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
format_parser-0.8.0 lib/parsers/psd_parser.rb
format_parser-0.7.0 lib/parsers/psd_parser.rb
format_parser-0.6.0 lib/parsers/psd_parser.rb
format_parser-0.5.2 lib/parsers/psd_parser.rb
format_parser-0.5.1 lib/parsers/psd_parser.rb
format_parser-0.5.0 lib/parsers/psd_parser.rb
format_parser-0.4.0 lib/parsers/psd_parser.rb
format_parser-0.3.5 lib/parsers/psd_parser.rb
format_parser-0.3.4 lib/parsers/psd_parser.rb
format_parser-0.3.3 lib/parsers/psd_parser.rb
format_parser-0.3.2 lib/parsers/psd_parser.rb
format_parser-0.3.1 lib/parsers/psd_parser.rb