Sha256: 684bdc8a1984fa3fdf9a71b90ecff3ed35f968824a2de26dabfcb542bbeec034

Contents?: true

Size: 1.16 KB

Versions: 23

Compression:

Stored size: 1.16 KB

Contents

class PSD
  # Describes the Header for the PSD file, which is the first section of the file.
  class Header < BinData::Record
    endian :big

    string  :sig, read_length: 4
    uint16  :version

    # Reserved bytes
    skip    length: 6

    uint16  :channels
    uint32  :rows
    uint32  :cols
    uint16  :depth
    uint16  :mode

    uint32  :color_data_len
    skip    length: :color_data_len

    # All of the color modes are stored internally as a short from 0-15.
    # This is a mapping of that value to a human-readable name.
    MODES = [
      'Bitmap',
      'GrayScale',
      'IndexedColor',
      'RGBColor',
      'CMYKColor',
      'HSLColor',
      'HSBColor',
      'Multichannel',
      'Duotone',
      'LabColor',
      'Gray16',
      'RGB48',
      'Lab48',
      'CMYK64',
      'DeepMultichannel',
      'Duotone16'
    ]

    # Get the human-readable color mode name.
    def mode_name
      if mode >= 0 && mode <= 15
        MODES[mode]
      else
        "(#{mode})"
      end
    end

    # Width of the entire document in pixels.
    def width
      cols
    end

    # Height of the entire document in pixels.
    def height
      rows
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
psd-1.5.0 lib/psd/header.rb
psd-1.4.5 lib/psd/header.rb
psd-1.4.4 lib/psd/header.rb
psd-1.4.3 lib/psd/header.rb
psd-1.4.2 lib/psd/header.rb
psd-1.4.1 lib/psd/header.rb
psd-1.4.0 lib/psd/header.rb
psd-1.3.3 lib/psd/header.rb
psd-1.3.2 lib/psd/header.rb
psd-1.3.0 lib/psd/header.rb
psd-1.2.2 lib/psd/header.rb
psd-1.2.1 lib/psd/header.rb
psd-1.2.0 lib/psd/header.rb
psd-1.1.1 lib/psd/header.rb
psd-1.1.0 lib/psd/header.rb
psd-1.0.0 lib/psd/header.rb
psd-0.4.2 lib/psd/header.rb
psd-0.4.1 lib/psd/header.rb
psd-0.4.0 lib/psd/header.rb
psd-0.3.5 lib/psd/header.rb