Split to Layers

This script will separate each contiguous group of pixels to its own layer.

In the example below, the layer “Image” was split into 3 separate layers.


Download “Split to Layers” script


34 Responses to “Split to Layers”

  1. Indo Says:

    Simply brilliant. Big thanks. I can’t wait to when there are three times as many scripts!

  2. The Insaint Says:

    Nice, but it throws an error after the dialog -> “the object current document is not currently availabel”
    Not useable on CS6

    • David Jensen Says:

      I created and tested it with Photoshop CS6, Standard and Extended, on both OSX and Windows. Can you give me any other info? Can you get it to work on something simple?

      Sometimes there is some initial state I didn’t anticipate, like the layer is locked, a path is active, quick mask mode is on, color mode is set to indexed, etc. (It shouldn’t fail in any of those specific cases, though)

      • The Insaint Says:

        Well … actually there isn’t any more info. :(
        I create a document, 500x500px, painting some strokes, then call the script. It starts, but soon, like after the first extraction, it stops with an error:
        Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop. – The object “current document” is not currently available.

        I tried on the locked background, I tried it on a transparent layer.
        Photoshop CS6 (13.0) on Win7 64Bit

        • David Jensen Says:

          Have you updated to I don’t know if that will help.
          If that isn’t it, I really don’t know. There have been a few hundred downloads of the script, and this is the first I’ve heard of any issues.

        • David Jensen Says:

          I just tested it on a copy of PS CS6 with no updates and it worked fine. Sorry, I really don’t know why it isn’t working for you :-/

    • ABER Says:

      make sure to unlock the layer that you want to split buddies
      it works!

  3. The Insaint Says:

    I haven’t updated PS, as I’m one of those many out there, where the updates don’t work/install (I’m no Adobe Cloud Member).
    Too bad, looks like I have to let this slip. :(
    Thanks anyway for the reply.

  4. The Insaint Says:

    Update: With help from Adobe Support, I was able to update to 13.1.2. Now the script works as expected.
    Great job.

  5. Alexander Says:

    This script grabs only full visibility pixels (when tolerance = 0)…
    How to remake it the script grabs no-full visibility pixels too (when tolerance = 0)?
    Answer please.

  6. Valerie Foster Says:

    This is fantastic. If I were able to append the filename with sequential letters of the alphabet, it would be perfect for my needs. Please stay in touch if you’re able to make these changes, I’ll happily come back and donate!!

  7. ABER Says:

    make sure to unlock the layer that you want to split buddies
    it works!

  8. Bernd.Kay Says:

    Works like a charm.

    One thing I miss so.. I often use complex forms imported from illustrator. If I split these with the script, they lose there form tag and get rastered. Any chance to keep them as vectors?.

    Right now I do it by hand. Select form with pressed Alt-Key, then new layer with Strg+Alt+J Keys..

    ANyway thanks alot! :-)

  9. Federico Says:

    Awesome, thanks! I wish this were available for Fireworks or Pixelmator, though.

  10. vik Says:

    hi I got Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop. – The command “Expand” is not currently available.

    what should I do?

  11. Konstantin Says:

    Thank you SO SO SO much! Works like a charm!

  12. GrutBrushes Says:

    What a great script! Thank you so much. If anyone is wondering, yes, it works perfectly in Photoshop CC 2014 Win 8.1 (select File->Scripts->Browse)

  13. mohamed osman Says:

    thanks!!!!!!!!!!!!!!!!!!!!!!!!! :D :D :D

  14. kakkakakaaaax Says:

    A BIG BIG thank to the Author, you are AWESOME, working perfectly on PS cs6 win 64bits!!!!

  15. Wambosa Says:

    This tool works great! i was about to write one myself for imageMagick, but who has time for that!

    When Getting this error:
    The command “Expand” is not currently available.
    Make sure that there are actual transparent pixels on the image. I found that if there are not any real transparent pixels, then this error comes up.

  16. Gaurav Ramanan Says:

    Just too awesome! EXACTLY what I was looking for. The example is a bit misleading though. At first I thought maybe the contiguous group of pixels need to be of the same colour! But this script does way more hard work! Cheers n Thanks!

  17. K Says:

    Hello my when I open script it asks how many pixels for continuous gap (may have the wrong) i leave 0 and all it seems to do is copy the photo with no layers

  18. Jill Schmehl Says:

    THANK YOU!!!

  19. J. Ferrand Says:

    Thank you. Very good work!!
    It works flawlessly!!!!

    It could be even better if it assumes the default values for gap and layer naming, after recording an action. As it is, you must press enter when asked for this values in the middle of an action.

    Photoshop CC 2015.1.1 on Mac OSX 10.11.2

  20. info@raypan.me Says:

    Oh my god! Saved my life!!!

  21. yapingyang (@yangyaping001) Says:

    当中国人用的时候要把脚本第414 和417 的 work path 改成 工作路径 后脚本就可以用了!
    When the Chinese used to change the script of 417 and 414 the work path to 工作路径 After the script can use!

  22. Yakoe Nicol Tablado Says:

    amazing thanks

  23. Matt Nava Says:

    For those of you encountering the error “The object “current document” is not currently available” using this script in CS6 (v13.0), I have just found the cause. The script will not work unless “Open Documents as Tabs” is checked in the preferences, under Interface. It seems unrelated but this is definitely why the script breaks. It’s too bad because I prefer to keep that unchecked!

    This is a very useful script, hope that issue can be fixed someday. Thanks!

  24. Andy Says:

    Saved me about 2 hours of work. Thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: