webtoon / psd

Fast zero-dependency PSD parser for the web and Node.js

Home Page:https://webtoon.github.io/psd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expand test suite

pastelmind opened this issue · comments

It would be nice to expand our test suite and test our library more rigorously. I don't have a clear plan, so I'm open to suggestions.

Some ideas:

Opening file

  • Fail: Empty file
  • Fail: File is too large (>2GB)

File Header

  • Fail: File Header is too small/truncated
  • Fail: Normal file with invalid signature (not ‘8BPS’, e.g. ‘FAIL’)
  • Fail: Normal file with lowercase signature (‘8bps’)
  • Fail: Normal file with invalid version (not 1)
    • PSB uses version number 2
  • Fail: Reserved segment contains nonzero values
  • Fail: Number of channels exceeds max (>56)
  • Fail: Image height > 30000
    • PSB has image height limit of 300,000
  • Fail: Image width > 30000
    • PSB has image width limit of 300,000
  • Fail: Invalid bits per channel (not in { 1, 8, 16, 32 })
  • Fail: Invalid color mode (not in { 0, 1, 2, 3, 4, 7, 8, 9 })

Color Mode

  • Fail: Missing or truncated color mode section
  • Success: Non-(indexed (2) or duotone (8)) image has empty Color Mode section
  • Fail: Non-indexed/duotone image has non-empty Color Mode section
  • Fail: Indexed image has invalid color table size (not 768)
  • ???: Duotone images have undocumented format—do we want to handle this?
    • Other apps should ignore/preserve this section if the image is duotone

Resources

  • Fail: Missing or truncated resources section

Resource block

  • Fail: Resource block is too small/truncated
  • Fail: Resource block has invalid signature (not ‘8BIM’)
  • Fail: Resource block has lowercase signature (‘8bim’)
  • Fail: Resource block has duplicate ID
  • Fail: Resource block has unknown ID value
(see https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_38034 for list of valid IDs)
  • Fail: Resource block name string is invalid
  • Fail: Resource block name string is not padded with zero (should we even check this?)
  • Fail: Resource data section is invalid (need more info)

Layer and Mask

  • Fail: L&M is missing or truncated

Layer Info

  • Fail: Layer length is not a multiple of 2
  • Fail: Layer info section is missing or truncated
  • Fail: Layer records are bad
  • Fail: Channel image data is bad

Layer Record

  • Fail: Blend mode signature is invalid (not ‘8BIM’)
  • Fail: Blend mode key is unknown (see Layer records for the full list)
  • Fail: Clipping value is invalid
  • Fail: Bits 5~7 are nonzero (should we even check this?)
  • Fail: Filler is nonzero
Layer mask/adjustment layer data
  • Fail: Length is not one of 0, 20, 36
  • Fail: Default color is neither 0 or 255
  • Fail: Bits 5~7 are nonzero (should we even check this?)
Layer blending ranges
  • Fail: Section is missing or truncated
Channel Image Data
  • Fail: Invalid compression method (not one of 0, 1, 2, 3)
  • Fail: Image data is missing or truncated
Additional Layer Info
  • Fail: ALI section is missing or truncated
  • Fail: Unknown key (see

Global layer mask info

  • Fail: Section is missing or truncated
  • Fail: Length is too short (< 13)

Image Data

  • Fail: Invalid compression method
  • Fail: Missing or truncated compressed data
  • Fail: Compressed data does not match compression method