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.15.1 lib/parsers/psd_parser.rb
format_parser-0.15.0 lib/parsers/psd_parser.rb
format_parser-0.14.1 lib/parsers/psd_parser.rb
format_parser-0.14.0 lib/parsers/psd_parser.rb
format_parser-0.13.6 lib/parsers/psd_parser.rb
format_parser-0.13.5 lib/parsers/psd_parser.rb
format_parser-0.13.4 lib/parsers/psd_parser.rb
format_parser-0.13.3 lib/parsers/psd_parser.rb
format_parser-0.13.2 lib/parsers/psd_parser.rb
format_parser-0.13.1 lib/parsers/psd_parser.rb
format_parser-0.13.0 lib/parsers/psd_parser.rb
format_parser-0.12.4 lib/parsers/psd_parser.rb
format_parser-0.12.2 lib/parsers/psd_parser.rb
format_parser-0.12.1 lib/parsers/psd_parser.rb
format_parser-0.12.0 lib/parsers/psd_parser.rb
format_parser-0.11.0 lib/parsers/psd_parser.rb
format_parser-0.10.0 lib/parsers/psd_parser.rb
format_parser-0.9.4 lib/parsers/psd_parser.rb
format_parser-0.9.3 lib/parsers/psd_parser.rb
format_parser-0.9.0 lib/parsers/psd_parser.rb