Skip to content

Instantly share code, notes, and snippets.

@dev-zzo
Last active September 25, 2019 11:49
Show Gist options
  • Save dev-zzo/11248826 to your computer and use it in GitHub Desktop.
Save dev-zzo/11248826 to your computer and use it in GitHub Desktop.
PXD File Format Description

PXD File Format Description

This file is created in response to rather poor documentation [1] for PXD file format consumed by Autodesk Pixlr and other peoducts (e.g., Autodesk SketchBook Pro).

File Layout

The PXD file, as noted by the few lines in the docs, consists of a header, followed by an array of layers, and then with composite pixel data (on versions >= 3?). All integers within the file are big-endian. The whole file is compressed with zlib.

File Header

  • Format version (16 bits), the latest one seems to be 3.
  • Color mode (16 bits), unknown domain.
  • Image width (32 bits).
  • Image height (32 bits).
  • Number of layers (16 bits).
  • Composite image offset (32 bits). Present only if the version >= 3.

Layers

  • Length of the layer data, bytes (32 bits). Excludes the length value itself.
  • Layer name (Pascal-type string with 16-bit length prepended).
  • Unknown value (8 bits).
  • Layer position (X) (32 bits).
  • Layer position (Y) (32 bits).
  • Layer width (32 bits).
  • Layer height (32 bits).
  • Opacity (8 bits). Domain: 0..100.
  • Visibility (8 bits, boolean).
  • Layer mode (8 bits). Known values: 0 = Normal, 1 = Add, 10 = Multiply, 11 = ???, 12 = Screen.
  • Unknown value (8 bits, boolean). Present only if the version > 1.
  • Length of bitmap data, bytes (32 bits). If > 0, bitmap data for this layer follows directly after this member.
  • Unknown value (32 bits).
  • Unknown value (8 bits). Appears to be a count. If > 0, some additional processing occurs.
  • Unknown value (16 bits). Appears to be a count. If > 0, some additional processing occurs.

References

[1] http://pixlr.com/developer/pxd

@photopea
Copy link

photopea commented Mar 5, 2019

Thanks a lot for this! I added the support for PXD files into www.Photopea.com :) It can also parse layer masks, text layers and layer styles (drop shadow, emboss ...).

@dgtart
Copy link

dgtart commented Sep 25, 2019

File Header:

version = pxd.readShort(); //PXD Version latest on flash is 3, will be 4 with the new html5 editor apps..
colormode = pxd.readShort(); //ColorMode 0=ARGB, 1=RGB, 2=BW
doc.width = pxd.readInt(); //Width
doc.height = pxd.readInt(); //Height
doc.numlayers = pxd.readShort(); //Number of Layers
if(version >= 3) pxd.readUnsignedInt(); //Location of flattened

Layers

layer.name = pxd.readUTF();
layer.type = pxd.readByte();
layer.x = pxd.readInt();
layer.y = pxd.readInt();
layer.width = pxd.readInt();
layer.height = pxd.readInt();
layer.alpha = pxd.readByte(); // value 0-100
layer.visible = pxd.readBoolean();
layer.blendMode = IntToBlendMode(pxd.readByte());
layer.alphaLock = pxd.readBoolean();

imageDataLength = pxd.readUnsignedInt(); //Length of image data
imageData = XX to imageDataLength ;

maskDataLength = pxd.readUnsignedInt(); //Length of image data
maskData = XX to maskDataLength ;

var amount:int = pxd.readByte(); //Nr of styles
ReadLayerStyles --
pxd.readUnsignedInt() -- Length of styleData
Each style has its own reader..

var amount:int = pxd.readShort(); //Nr of resourceblocks
ReadLayerResources --
pxd.readUnsignedInt() -- Length of resourceData
Each resource has its own reader..

-- Next layer --
//

Types
case 0: LayerType.Bitmap;
case 1: LayerType.Text;
case 2: LayerType.Shape;

BlendModes
case 0: "normal";
case 1: "add";
case 2: "alpha";
case 3: "darken";
case 4: "difference";
case 5: "erase";
case 6: "hardlight";
case 7: "invert";
case 8: "layer";
case 9: "lighten";
case 10: "multiply";
case 11: "overlay";
case 12: "screen";
case 13: "subtract";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment