Photoshop: PSD to XML conversion

  • 1
  • Question
  • Updated 1 year ago
  • (Edited)
I want some information related to plugins for photoshop. I have a requirement where in I have a PSD in the format of groups containing multiple layers. I want to convert this PSD in XML format containing grouped level of information. I had got some of the plugins available online but they were un-grouping all the layers and providing all layers in single hierarchy.Also I am also trying to get text layer distinction from image layer. Any help is appreciated.
Photo of Navani Srivastava

Navani Srivastava

  • 4 Posts
  • 1 Reply Like

Posted 1 year ago

  • 1
Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
Could we get some more information, please?

Are you writing a full plugin in C#, scripting in javascript, or writing a node panel extension?

What plugins have you already tried?
Photo of Navani Srivastava

Navani Srivastava

  • 4 Posts
  • 1 Reply Like
Yes, sure.

I am trying to write this plugin in java script and I was referring the script available in https://github.com/jwa107/Photoshop-E... with minor changes like redirecting all properties data to XML file.
(Edited)
Photo of Navani Srivastava

Navani Srivastava

  • 4 Posts
  • 1 Reply Like
12 days before there was a checkin on the link mentioned above, and that checkin brings fetching layers in the form of groups created functionality. So looks like one issue is resolved. It would be really a great help if I can get to know how to distinguish text layer from image layer? Thanks
Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
If you follow the link @Jeff posted to the scripting documentation, there's a javascript photoshop reference PDF that has the properties for artLayer. There's a "kind" property with the following enum results:
BLACKANDWHITEBRIGHTNESSCONTRAST
CHANNELMIXER
COLORBALANCE
CURVES
EXPOSURE
GRADIENTFILL
GRADIENTMAP
HUESATURATION
INVERSION
LEVELS
NORMAL
PATTERNFILL
PHOTOFILTER
POSTERIZE
SELECTIVECOLOR
SMARTOBJECT
SOLIDFILL
TEXT
THRESHOLD
LAYER3D
VIBRANCE
VIDEO

In the script you posted, there's a function isAdjustmentLayer(layer) that should show you exactly how to find what you need for the text layer check.

if (layer.kind == LayerKind.TEXT ) { doTheThing();}
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14147 Posts
  • 1765 Reply Likes
Yes, the scripting API should allow you to distinguish between pixel layers and text layers. You can find the reference documentation here: https://www.adobe.com/devnet/photoshop/scripting.html

Also, check out https://www.ps-scripts.com - it's a community focused entirely on scripting Photoshop.
Photo of Navani Srivastava

Navani Srivastava

  • 4 Posts
  • 1 Reply Like
@Jeffrey @Max Thanks a lot for your inputs. This is exactly what I was looking for. I am sure I should be able to create the desired XML now
Photo of Ranit Sanyal

Ranit Sanyal

  • 1 Post
  • 0 Reply Likes
What I noticed with using scripts is that it doesn't provide desired results if the flow is little complex. Most of the time when working on unique designs automation didn't helped me. Later I had to use PSD to XML conversion service and then with human interaction I got my job done. 

Automation still have a long way to go, though what Adobe is doing I am really optimistic about the future.