# Method Image.PSD.__decode()

Method __decode

  `mapping __decode(string|mapping data)`

Description

  Decodes a PSD image to a mapping, defined as follows.

  `"channels" : int(1..24)` | The number of channels in the image, including any alpha channels.
  `"height" : int(1..30000)` | The image dimensions.
  `"width" : int(1..30000)`
  `"compression" : bool` | 1 if the image is compressed, 0 if not.
  `"depth" : int(1..1)|int(8..8)|int(16..16)` | The number of bits per channel.

  `"mode" : int(0..4)|int(7..9)`

  The color mode of the file.

  `0` | Bitmap
  `1` | Greyscale
  `2` | Indexed
  `3` | RGB
  `4` | CMYK
  `7` | Multichannel
  `8` | Duotone
  `9` | Lab

  `"color_data" : string` | Raw color data.
  `"image_data" : string` | Ram image data.
  `"resources" : mapping(string|int:mixed)` | Additional image data. See mappping below.
  `"layers" : array(Layer)` | An array with the layers of the image. See mapping below.

  The resources mapping. Unknown resources will be identified by their ID number (as an int).

  `"caption" : string` | Image caption.
  `"url" : string` | Image associated URL.
  `"active_layer" : int` | Which layer is active.

  `"guides" : array(mapping(string:int))`

  An array with all guides stored in the image file.

  `"pos" : int` | The position of the guide.
  `"vertical" : bool` | 1 if the guide is vertical, 0 if it is horizontal.

  `"resinfo" : mapping(string:int)`

  Resolution information

  `"hres" : int` | FIXME: Document these.
  `"hres_unit" : int`
  `"width_unit" : int`
  `"vres" : int`
  `"vres_unit" : int`
  `"height_unit" : int`

  The layer members:

  `"top" : int` | The rectangle containing the contents of the layer.
  `"left" : int`
  `"right" : int`
  `"bottom" : int`
  `"mask_top" : int` | FIXME: Document these
  `"mask_left" : int`
  `"mask_right" : int`
  `"mask_bottom" : int`
  `"mask_flags" : int`
  `"opacity" : int(8bit)` | 0=transparent, 255=opaque.
  `"clipping" : int` | 0=base, 1=non-base.
  `"flags" : int` | bit 0=transparency protected bit 1=visible

  `"mode" : string`

  Blend mode.

  `"norm"` | Normal
  `"dark"` | Darken
  `"lite"` | Lighten
  `"hue "` | Hue
  `"sat "` | Saturation
  `"colr"` | Color
  `"lum "` | Luminosity
  `"mul "` | Multiply
  `"scrn"` | Screen
  `"diss"` | Dissolve
  `"over"` | Overlay
  `"hLit"` | Hard light
  `"sLit"` | Soft light
  `"diff"` | Difference

  `"extra_data" : string` | Raw extra data.
  `"name" : string` | The name of the layer

  `"channels" : array(mapping(string:int|string))`

  The channels of the layer. Each array element is a mapping as follows

  `"id" : int`

  The ID of the channel

  `-2` | User supplied layer mask
  `-1` | Transparency mask
  `0` | Red
  `1` | Green
  `2` | Blue

  `"data" : string` | The image data