Skip to content

ag-psd text layers have 0x0 dimensions - not following Adobe PSD specification for TypeTool ('TySh' key) #251

Description

@aamirsdev

Issue Description:

Problem Summary

Text layers created with ag-psd consistently show 0x0 dimensions and appear invisible in Photoshop, despite correct input parameters. Analysis shows ag-psd is not implementing
Adobe's official PSD specification for TypeTool data structure.

Expected Behavior

Text layers should:

  • Have correct bounding dimensions matching input width/height
  • Be visible and editable in Photoshop
  • Follow Adobe's official 'TySh' key specification

Actual Behavior

Text layers consistently show:

  • Bounds: left=X, top=Y, right=X, bottom=Y (0x0 dimensions)
  • Invisible text in Photoshop
  • Photoshop warnings when opening files

Code to Reproduce

const { writePsd } = require('ag-psd');

const psd = {
width: 200,
height: 200,
children: [
{
name: 'Test Text',
left: 50,
top: 50,
right: 150,
bottom: 80,
text: {
text: 'Hello World',
transform: [1, 0, 0, 1, 50, 50],
style: {
font: { name: 'Arial' },
fontSize: 24,
fillColor: { r: 0, g: 0, b: 0 }
}
}
}
]
};

const buffer = writePsd(psd);
// Result: Text layer has 0x0 dimensions

Analysis: Adobe Specification Compliance

According to https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_72092, TypeTool ('TySh' key) requires:

  • Version: 1 (2 bytes)
  • Transform: 6 doubles (xx, xy, yx, yy, tx, ty)
  • Text version: 50 (2 bytes)
  • Descriptor version: 16 (4 bytes)
  • Text data descriptor (variable)
  • Warp version: 1 (2 bytes)
  • Descriptor version: 16 (4 bytes)
  • Warp data descriptor (variable)
  • Bounding rectangle: 4 doubles (left, top, right, bottom)

ag-psd appears to be missing:

  1. Required version numbers (Text version: 50, Descriptor version: 16)
  2. Proper descriptor structure for text data
  3. Warp data descriptor implementation
  4. Correct bounding rectangle handling

Testing Results

Multiple approaches tested, all resulting in 0x0 dimensions:

  1. Manual bounds setting: left: 50, top: 50, right: 150, bottom: 80
  2. No manual bounds (auto-calculation): Still 0x0
  3. Different transform matrices: No improvement
  4. Various text styling options: No improvement

PSD Analysis Tool Output:
Layer: "Test Text"
├─ Bounds: left=50, top=50, right=50, bottom=50
├─ Dimensions: 0x0
├─ TEXT LAYER DETECTED: Present
└─ Error reading type tool data: typeToolResult.transform.join is not a function

Environment

  • ag-psd version: 28.3.1 (latest)
  • Node.js version: [your version]
  • OS: Windows/Mac/Linux
  • Photoshop version: [if testing with Photoshop]

Proposed Solution

ag-psd should implement the complete Adobe TypeTool specification including:

  1. Proper version number handling
  2. Complete descriptor structure implementation
  3. Warp data descriptor support
  4. Correct bounding rectangle calculation from text metrics

Workaround

Currently using rasterized text layers as a fallback, but this eliminates editability which is a key PSD feature.

Additional Notes

This issue affects any application trying to generate PSDs with editable text layers. The current implementation makes ag-psd unsuitable for professional PSD generation workflows
requiring text editability.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions