• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

General purpose parser for the markup format used in PSD files

PSD EngineData

Adobe thought it would be cool to create their own markup language for text data embedded within a Photoshop document. I've taken the liberty of calling it EngineData since that is the name used in the descriptor embedded within PSD files. This is a general purpose parser for that data.

Installation

Add this line to your application's Gemfile:

gem 'psd-enginedata'

And then execute:

$ bundle

Or install it yourself as:

$ gem install psd-enginedata

Usage

# From File
parser = PSD::EngineData.load('path/to/file')

# From string
parser = PSD::EngineData.new(text)

# Parse it
parser.parse!

# Use it
puts parser.result.Editor.Text

File Spec

The EngineData format uses certain characters to denote various data types. All newlines are denoted with a UNIX newline (\n) and it is not indentation-aware (although it seems to be stored with pretty indentation in the PSD file).

<<
  /EngineDict
  <<
    /Editor
    <<
      /Text (˛ˇMake a change and save.)
    >>
  >>
  /Font
  <<
    /Name (˛ˇHelveticaNeue-Light)
    /FillColor
    <<
      /Type 1
      /Values [ 1.0 0.0 0.0 0.0 ]
    >>
    /StyleSheetSet [
    <<
      /Name (˛ˇNormal RGB)
    >>
    ]
  >>
>>

There are 6 data types available to use:

  • Dictionary/Hash
  • Array (single or multi-line)
  • Float
  • Integer
  • String
  • Boolean

Altogether we have a non-turing complete markup language with some interesting quirks that was written in 1998 with the release of Photoshop 5.0 since it included the ability to edit text areas after they were created (before that, they were rasterized immediately).

Property Names

Property names are started with a / followed by an alphanumeric word. The property value either comes after a space or a new line.

Dictionaries/Hashes

Dictionaries are denoted by a property name (unless at the root), followed by a new line and the << instruction. The end of a dictionary is denoted by the >> instruction.

A dictionary can contain any type of data including more dictionaries for nesting purposes. All values within a dictionary must have a property followed by a value of some kind.

Arrays

Arrays come in two flavors: single-line or multi-line. Both are denoted by square brackets [ ].

Single-line arrays can only hold number values (doubles or integers). While it wouldn't be out of the question for it to hold string or boolean values, this does not seem to appear in any tested Photoshop documents so we're going to assume it's not a part of the specification. Values in single-line arrays are space delimited. There seems to be a space between the opening and closing square brackets and the data, but we assume it's optional.

Multi-line arrays can contain any type of data. Values in multi-line arrays are newline-denoted. The opening bracket for multi-line arrays must occur on the same line as the property to which it belongs.

Floats/Integers

Basically, numbers can be expressed with or without a decimal point. Floats are of the form 1.76, but the non-fractional digits to the left of the decimal point are optional. Integers are just numbers with no commas or decimal points.

Strings

Strings are delimited by parentheses with a cedilla-breve (thanks Rob for the terminology) at the start of the string. Since operations are UNIX newline (\n) delimited within the document, new lines in strings are denoted by carriage returns (\r).

Booleans

Booleans are simply denoted by true or false. Cool.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

More Repositories

1

psd.rb

Parse Photoshop files in Ruby with ease
Ruby
3,123
star
2

jquery.typer.js

A simple jQuery plugin for a slick typing effect.
JavaScript
745
star
3

divergence

A HTTP proxy that lets you map subdomains to git branches for site testing
Ruby
408
star
4

jquery.haircut.js

Haircut trims text down to fits into its container.
JavaScript
142
star
5

jquery.data.filter

Better jQuery data-* filtering
JavaScript
86
star
6

jquery.text.fadeto.js

jQuery library for fading text elements using CSS3 transitions
JavaScript
71
star
7

psd_native

Native mixins for PSD.rb that improve its performance.
C
67
star
8

ase.rb

Reader/writer for Adobe Swatch Exchange files in Ruby
Ruby
48
star
9

jquery.image.fadeto.js

A jQuery library for cross-fading images on the fly.
JavaScript
38
star
10

jquery.input.textslider.js

Emulates the Photoshop-style slidertext inputs
JavaScript
32
star
11

dn_ruby_client

Ruby gem for communicating with the Designer News API
Ruby
23
star
12

disk_store

ActiveSupport::Cache::Store-like gem for caching big files on disk
Ruby
17
star
13

LVDebounce

An Objective-C library for debouncing NSTimers
Objective-C
14
star
14

jquery.image.enhance.js

Enlarge images in a QuickLook-esque style.
JavaScript
14
star
15

layervault_js_client

NodeJS client for the LayerVault API
CoffeeScript
12
star
16

LayerVaultAPI.objc

LayerVault API Objective-C Library
Objective-C
12
star
17

layervault_ruby_client

This is the Ruby LayerVault API client.
Ruby
11
star
18

api

The LayerVault API documentation.
10
star
19

pummeldoge

Wow, such great example API app
Ruby
9
star
20

LVScreensaver

An example API app written in Objective-C. It's a screensaver that displays the latest designs in your LayerVault.
Objective-C
8
star
21

sidekiq-gelf-rb

Sidekiq logging to a GELF-supported server, such as Graylog2
Ruby
8
star
22

designer_news_js_client

NodeJS library for the Designer News API
CoffeeScript
8
star
23

ember-cli-stripejs

An ember-cli addon for using StripeJS in your application
JavaScript
5
star
24

omniauth-layervault

Official OmniAuth provider for LayerVault
Ruby
3
star
25

lv-jekyll-plugins

Jekyll tags for LayerVault public pages
Ruby
2
star
26

psd.tp

Test definitions for PSD parsers
1
star