Skip to main content
Participant
April 7, 2011
Question

Export Slice Coordinates To XML/Text File?

  • April 7, 2011
  • 2 replies
  • 2305 views

Hi, wondering if I can export coordinates from slices using the API (with JavaScript or AppleScript).

I need to get the x, y, width, and height of sliced areas, not to use as slices, but I figured slices would be best since I noticed it shows those data values in the properties when you double click a slice.

Rather than copying/pasting from the slice properties' fields, I figured it would be easier to just export all this data to a xml or text file.

This topic has been closed for replies.

2 replies

Participant
May 7, 2018

For others having the same question, since the ps-scripts link no longer works:

  1. Use Save for Web
  2. Click Save
  3. Format: HTML only (or HTML and Images if you haven't saved the images already)
  4. Settings: Other > this will create a new prompt called Output Settings
  5. Second Dropdown (HTML, Slices, Background, Save Files): Choose Slices
  6. Slice Output: Generate CSS, Referenced By ID
  7. Now press OK and save the html file
  8. Open the html file in your favourite text editor, each slice will have its own CSS with absolute positions for left, top, width and height (x, y, w, h for your image map)
  9. If you have a text editor that supports multi-line editing, it'll be easy to just select all the IDs and edit the 4 lines to bring back your 4 values.

Edit: Tested in Photoshop CC 2018

Inspiring
April 7, 2011

You can use SaveForWeb to output the slices info http://ps-scripts.com/bb/viewtopic.php?t=1445

You can also use Exiftool to get the raw slices descriptor from a document. But the above is much eaiser to deal with.