What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

areas to each layer


diki

Member
Messages
13
Likes
0
Hello.

I'm looking for a quick way to make each of the black areas into separate layers (in this case I end up with 10 new layers - each having its black square)

ph.jpg

Thanks!


p.s. I know I can select each area and do ctrl-X and ctrl-V. Or Ctrl-Shift-J (that puts the selection to new layer) I'm looking for a faster way because sometimes I have more than 10 areas.
 
Last edited:

thebestcpu

Guru
Messages
2,988
Likes
2,747
Hi Diki
If you want fully automated I think you would need a script.
Here is a productive way to do it manually

1) With magic wand tool select first black object with contiguous option
2) Shift + Cmd/Ctrl + J to cut the object to its own Layer (one Layer above)
3) Opt/Alt + [ to jump down to original Layer below this newly created Layer
4) Jump back to #1 and continue with the next object until all objects are done

Note that if you want to preserve the original Layer then use Cmd/Ctrl + J to copy the object instead of the shortcut to "cut" the object.

Hope that helps.
 

diki

Member
Messages
13
Likes
0
yep for the moment I was doing it like that.
I select (with M) manually a shape at the time and then:

(cmd j) cuts selection to new layer above;
(cmd alt shift H) I made this shorcut for hiding the created layer (so that I can see wich shape is next);
(alt ,) returns to the background layer.

and put these in a small program called "Spark" that runs those three shortcuts with one shortcut.

If you guys find a script or something, that would be great. I'm just learning a bit of applescript and I think I can handle it.
I thought I could find an automation for such a problem, but maybe not enough people run into this.
And I don't think this could be hard to program. You detect where are 'isles' of pixels and put each one into a layer.
 

MrToM

Guru
Messages
3,595
Likes
3,321
There was a similar question a while back.....but I'm darned if I can find it now.

The member need small blocks of an image, a diffuse map I think, putting onto individual layers so they could be arranged more efficiently.

I'm sure a script was written for it but it eludes me for the moment.... Paul MR is probably the person who wrote it so maybe he remembers it?

I could be wrong about the script but the thread is definitely here somewhere....

I'll keep looking.

Regards.
MrToM.
 

IamSam

Administrator
Staff member
Administrator
Messages
22,721
Likes
13,258
Hello and welcome to PSG.

My first suggestion is when you create the black rectangles, create them on their own layers from the start. This will save you from having to do it later.

Select the layer containing the black rectangles (layer 1 in your example) using the Magic Wand Tool to make your selection of the top left rectangle, then hit Cmd/Cntrl + J to copy the selection to it's own layer, re-select the layer 1 (Opt/Alt + comma ), repeat with the next rectangle. Do them all. There's no need to Cmd/Cntrl + x (cut) them out.

This takes maybe 2 or 3 seconds to do so it goes very fast.

EDIT: I posted this this morning right after the question/thread appeared. I got the PSG spinning wheel of death so I just left it alone while I went to work. I guess it did not get posted. I post it now just to let you know that I agree with thebestcpu.
 

MrToM

Guru
Messages
3,595
Likes
3,321
The quickest way I know, as I can't find that thread, is to start as Sam suggested with just one black rectangle on its own layer.

Deselect everything....this is important!

With that layer selected hold down Ctrl + Alt and drag the rectangle to the next position....repeat for as many rectangles as you need.

This will create a duplicate of the rectangle, on a new layer, each and every time you move it.....so don't drop till your ready......holding 'Shift' will constrain as normal.

If you use CC 2014 or later you'll also have the advantage of the positioning info so you can drop precisely where you want it.

Regards.
MrToM.
 

diki

Member
Messages
13
Likes
0
The black rectangles are actually thumbnails of video stills that I hided making them black.
I edit videos and I often have to take snapshots of several movie files, print them and then cut each scene in a little square.
I can move them easily in my script/storyboard this way.

Since I know how to use Photoshop, I thought I could do all this on the computer with layers.

So I select all the movie clips I have in a folder, I get the big icon preview of each one. And I take a snapshot of all.
Then in Photoshop I cut and paste so that I have each thumbnail on a different layer.
This way I hit V (direction tool) and I can move easily the thumbnails by holding Cmd. (in this way I avoid having to select the right layer)
 
Last edited:

Paul MR

The Script Master
Messages
382
Likes
206
This should work if the document has transparency.
It selects the transparency, inverts, creates a Work Path. Then selects each sub-path and puts it on its own layer.
Code:
#target photoshop
app.bringToFront();

main();
function main(){
if(!documents.length) return;
selectTransparency();
try{
    var SB=activeDocument.selection.bounds;
    }catch(e){
        alert("No selection has been made!");
        return;
        }
app.activeDocument.selection.makeWorkPath(0.5);
try{
activeDocument.pathItems.getByName('Work Path').name='WP';
}catch(e){
    alert("Work Path does not exist!");
    return;
    }
var currentRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var res = app.activeDocument.resolution;
if( res != 72 ) app.activeDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
var pathLayer = activeDocument.activeLayer;   
var pathInfo = activeDocument.pathItems.getByName('WP');
var sp = pathInfo.subPathItems.length;
for(var a = 0;a<sp;a++){
      var tempPath = app.activeDocument.pathItems.add("Temp Path", extractSubPathInfo('WP',a));
      tempPath.makeSelection();
      executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
      tempPath.remove();
      activeDocument.activeLayer = pathLayer;
}
 if( res != 72 ) app.activeDocument.resizeImage (undefined, undefined, res, ResampleMethod.NONE);
 pathInfo.remove();
 app.preferences.rulerUnits = currentRulerUnits;
 }
  
function extractSubPathInfo(pathName,subPathNo){
var pathObj = activeDocument.pathItems.getByName(pathName)
    var pathArray = new Array();
        var pArray = new Array();
          for(var i=0;i<pathObj.subPathItems[subPathNo].pathPoints.length;i++){
             pArray[i] = new PathPointInfo;
             pArray[i].kind = pathObj.subPathItems[subPathNo].pathPoints[i].kind;
             pArray[i].anchor = pathObj.subPathItems[subPathNo].pathPoints[i].anchor;
             pArray[i].leftDirection = pathObj.subPathItems[subPathNo].pathPoints[i].leftDirection;
             pArray[i].rightDirection = pathObj.subPathItems[subPathNo].pathPoints[i].rightDirection;
          };
        pathArray[pathArray.length] = new Array();
        pathArray[pathArray.length - 1] = new SubPathInfo();
        pathArray[pathArray.length - 1].operation = pathObj.subPathItems[subPathNo].operation;
        pathArray[pathArray.length - 1].closed = pathObj.subPathItems[subPathNo].closed;
        pathArray[pathArray.length - 1].entireSubPath = pArray;
    return pathArray;
};
function selectTransparency() {
    var desc113 = new ActionDescriptor();
        var ref83 = new ActionReference();
        ref83.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
    desc113.putReference( charIDToTypeID('null'), ref83 );
        var ref84 = new ActionReference();
        ref84.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
    desc113.putReference( charIDToTypeID('T   '), ref84 );
    try{
    executeAction( charIDToTypeID('setd'), desc113, DialogModes.NO );
    }catch(e){}
};
 

diki

Member
Messages
13
Likes
0
Oh man thanks a lot for this work!
Now I google a bit to see how to run this xD lol I don't have much experience with scripting in Photoshop.
Looks like JavaScript... wow.. thanks again Paul ; )
 

Paul MR

The Script Master
Messages
382
Likes
206
Copy and paste the script into a PLAIN TEXT editor or better yet ExtendScript Toolkit (Adobe's IDE) that is normally installed with Photoshop (CC is a seperate install).
Save the script with a ".jsx" extension then save or copy to:-
N.B. On Windows 7/8 you will have to save it where you have permissions (Desktop) then copy it.
[h=4]PC:- C:/Program Files/Adobe/Adobe Photoshop CS#/Presets/Scripts/
Mac:- [hard drive]/Applications/Adobe Photoshop CS#/Presets/Scripts/[/h]
If Photoshop was open close and restart it.
To use, have your document open, File - Scripts - Select the script.
 

diki

Member
Messages
13
Likes
0
Hey Paul.. I'm just starting to learn Scripting..
I'm reading on AppleScript mostly and a bit on JavaScript. But I'm finding it very hard.
Do you have any suggestion or books or courses you found usefull?
Or you think maybe one just have this ability or doesn't and it's useless to try...
Or maybe it just takes time and anyone can do it.
Any suggestion would help.

Thank you very much!!!!!!!!!
 
Last edited:

Paul MR

The Script Master
Messages
382
Likes
206
There isn't that much documentation at all. Most people use JavaScript as its cross platform and you will get most help with that.
There is help built in with ExtendScript Toolkit
There is an excellent ScriptUI for Dummies document http://www.kahrel.plus.com/indesign/scriptui.html
There used to be two forums, but one has closed due to the demise of Mike Hale www.ps-scripts.com but there is an archive that you can still look through:
https://web.archive.org/web/20150315052523/http://ps-scripts.com/bb/index.php
Then there is the Adobe scripting forum: https://forums.adobe.com/community/photoshop/photoshop_scripting/content
Good luck, there is a bit of a learning curve!
 

diki

Member
Messages
13
Likes
0
Thanks for the infos!!

I thought it was my fault for not finding good resources.
I'm reading several books, but I find them very hard. I'm a visual learner and if I don't see exaples of what you are talking about I don't get it.
The only few things I've learned was from video courses and from tutorials I found online.
But usually people rarely help you. Even in forums (here is a positive exception:) where they should be the best place to learn faster something, you find that people are very protective of their knowledge. and not always help.
So we have all this knowledge and yet if we want to learn something we have to reinvent the wheel by starting to learn everything from zero.. wasting a lot of time. Failing on thing million of others have already failed. Why we have to keep failing when we know the solution?
I hope in the future forums will be the best way to learn. And not waste countless hours learning isolated by our own trying to decifer from an incomprehensible book or a cold online tutorial.
 

diki

Member
Messages
13
Likes
0
Thanks revnart! I tried it and it works :thumbsup:

I'm not understanding the "Split when gap is larger than _ pixels" though.
Can you explain me what it does? Maybe it could be useful for something I do.
 

revnart

Power User
Messages
362
Likes
327
On this example:
Assume that there is 10px distance between those rectangles, but one of them is closer.. Like 5px.. Then if you run the script all and set radius of 7 all rectangles will be cut but not the one which is closer. Hope you understand because English is not my native language :)
 

diki

Member
Messages
13
Likes
0
Perfect. Thanks. I understand now : )
I'm using it with Media Militia's "white bg removal" action (so that I have a transparent background)
And it works very well.
 

Top