Slice PSD
---------

This script reads a PSD file from standard input, extracts the Slices
thar are defined in the image (if any) and outputs a convert statement
that wil crop slice an PNG with the same size as the PSD and write
the output slices in a directory.

From my posting on our blog (http://blog.easytech.com.ar):

"Graphic designers, when creating websites, will often give programmers the
Photoshop (PSD) files of the screens and, if they have enough experience
designing for the web, they will 'slice' the design. Basically what they'll do
is mark a rectangular region (a 'slice') of the image that will then be used
in the HTML of the page. Often a single page is composed of many such slices.
When the designer is happy with his work he will save in one shot all the
slices and provide de programmer with the slices and PSD files in case you
need to modify anything. If you buy templates from templating sites such as
Template Monster (www.templatemonster.com) you will receive the HTML, slices
and PSD files. 

Here in Easytech we mostly use The Gimp to read and modify PSD files. The Gimp
can read and write PSD files with no problem, preserving layout information,
etc. Unfortunately, it has no slice support and completely ignores all slice
information stored on the PSD file. After looking a while for an alternative I
was disapointed I couldn't find one. What I did find is a little document
which describes an old PSD file format
(http://www.fileformat.info/format/psd/spec/03771aa3c5f144cdac75843737984b02)
and a C# parser which understands the Slices
(http://www.codeproject.com/KB/graphics/PSDParser.aspx) section of the PSD
file. With this information and a hex editor and some sample PSD files I was
able to write a little PHP script which basically outputs a list of convert
statements which can be used to slice an image. 

To use the script:

 1. Save the PSD file as a PNG
 2. Run this script on the PSD file
 3. Run the resulting converts on the PNG file to slice it up!
    
This code is quite simple and was written over a weekend so its quite
rudimentary. It has almost no error checking and is more a proof of
principle. If I need something more sofisticated then this is a good
starting point.

first thing I should probably do is split the program into two smaller
programs: one to write an XML document describing the slices and a second
program that processes this document and writes the convert statements.
Another option is probably create a couple of Classes to make the code
more re-usable. Maybe later... for the moment have fun with it! "

CONTACT:
-------

To contact me you can write to: cesar.miquel@easytech.com.ar. Our company
site: http://www.easytech.com.ar (in case you need professional 
assistance :-) )

LICENSE:
-------

This software is distributed under the GNU LESSER GENERAL PUBLIC LICENSE. Read
license.txt for more information.
