Sha256: 88a1f5b4967541dee9d1ee9a74e17bf49ac7584313ca09eac329e01a0f6f47ee

Contents?: true

Size: 577 Bytes

Versions: 6

Compression:

Stored size: 577 Bytes

Contents

class FormatParser::PSDParser
  PSD_HEADER = [0x38, 0x42, 0x50, 0x53]
  include FormatParser::IOUtils

  def information_from_io(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::FileInformation.image(
      file_type: :psd,
      width_px: w,
      height_px: h,
    )
  end

  FormatParser.register_parser_constructor self
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
format_parser-0.1.7 lib/parsers/psd_parser.rb
format_parser-0.1.6 lib/parsers/psd_parser.rb
format_parser-0.1.5 lib/parsers/psd_parser.rb
format_parser-0.1.4 lib/parsers/psd_parser.rb
format_parser-0.1.3 lib/parsers/psd_parser.rb
format_parser-0.1.2 lib/parsers/psd_parser.rb