How to add a clipping with Photoshop scripts path

Hi guys,.

I make a script that will save me a lot of time in the future with photo editing.

When I take a picture of a product, it always has a background. When I removed background, I want a script to load the layer (while the product inside the PSD bottomless) and save the selection as a clipping path. Does anyone know how to do?

Thanks in advance!

Something like that...

#target photoshop;
if(documents.length) main();
function main(){
var doc = activeDocument;
selectLayerData();
doc.selection.makeWorkPath(0.1);
doc.pathItems[0].name="Clipping Mask";
doc.pathItems[0].makeClippingPath(0.5);
doc.pathItems[0].deselect()
doc.selection.deselect();
}
function selectLayerData() {
var desc2 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
desc2.putReference( charIDToTypeID('null'), ref1 );
var ref2 = new ActionReference();
ref2.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
desc2.putReference( charIDToTypeID('T   '), ref2 );
executeAction( charIDToTypeID('setd'), desc2, DialogModes.NO );
};

Tags: Photoshop

Similar Questions

  • How to add the document level java script to the document via API?

    Hello

    Can someone tell me how to add a document level java script with pdf document?

    Thank you

    Amol

    Here is a link to the JavaScript documentation for the doc.addScript method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.440.html

  • Make a group of clipping with a compound path

    So, as of today, I am new to scripting for Illustrator, I use the ExtendScript Toolkit. However, I am not new to my own script solutions and I do not have any experience with JavaScript.

    What I'm trying to do is the following: for all selected items-> duplicate selected item and make a group of simple clipping with it

    What I'm left with visually does not change the picture, but gives me a lot of clipped colored areas that I then can I change in isolated mode, which allows me good shading faster and better. That the doing by hand takes hours on some pictures, it would take a second with a script.

    The script itself is already works for normal PathItems. As evident in the title, as soon as I have to apply the same thing to CompundPathItems things stop working. My question is a bit like this old thread [problem with clipping path transparent], but I couldn't find a solution because I get different behavior.

    When I run the same script that works perfectly with the normal PathItems with CompoundPathItems I get this: 9046 error: the top element in the group must be a path element to create a mask

    Well, it's a problem. There is absolutely no difference between making a clipping with a simple path mask and a compound path in the GUI. Frankly reference guide not helped with this problem at all, the only thing that I learned from it is that the CompoundPathItem object is an attribute of cutting, but those included PathItems.

    Here's what I have so far:


    If ([i] selected. TypeName == 'PathItem') {}
    newGroup var = doc.groupItems.add ();
    copy is selected [i] .duplicate (newGroup, ElementPlacement.PLACEATEND);.
    Selected [i] .moveToBeginning (newgroup);
    newGroup.clipped = true;

    }

    As I said, this part is exactly what it is supposed to do for normal paths.

    For CompoundPaths, I use this work around.

    If ([i] selected. TypeName == 'CompoundPathItem') {}
    newGroup var = doc.groupItems.add ();
    copy is selected [i] .duplicate (newGroup, ElementPlacement.PLACEATEND);.
    Selected [i] .moveToBeginning (newgroup);
    compoundItems = selected [i] .pathItems;
    compoundIndex = compoundItems.length;
    for (f = 0; f < compoundIndex; f ++) {compoundItems [f] .clipping = true ;}
    var lineList = new array (10);
    for (l = 0; l < lineList.length; l ++) {lineList [l] = new Array (I * 10 + 50, ((i-5) ^ 2) * 5 + 50) ;}}
    newPath = app.activeDocument.pathItems.add ();
    newPath.setEntirePath (lineList);
    newPath.moveToBeginning (newGroup);
    newGroup.clipped = true;
    newPath.remove ();

    Mind you, this workaround works in so far that it ignores that annoying error and evil and composite clipping path also works with the only problem being that created composite clipping path as it is always displayed in its original colours in the layers section and is always selectable. When I lock the composite clipping path I can work with it, but still...

    So the question is, what am I missing here? Surely, there must be a good way to do this.

    app.executeMenuCommand ()? That is me away so far, might be just the right thing. I will definitely take a look, now just to find a ref about it, because unfortunately official documents Ref I do not mention this command. Any place with a list of possible commands?

    Ah, also of course I only do for the isolation mode. If you care to hear the background, it is here:

    As I said it's for photos of shading, I'm working on. I repeated and tried through a bunch of techniques. For example, gradient mesh on my first few true works. Now these cracks don't do well with complex shapes, which previously I mitigated by using a simple square or rectangle gradient mesh and using the original form as a color clipping mask. It worked, but it was a huge field of work.

    After a lot of attempts that I went to the use of simple gradients as a background for the form, and then I do the shading freehand with the blob Brush tool, using a graphic style and filters to make it look like to the right. Is better, but do it right all the clipping masks takes me much more time than anything else.

    Now the problem is that shading is not supposed to cross the lines, it's impossible to do correctly without messing up the order, either using clipping masks, where the script. Because you know, if you use a form of the task with a strong Gaussian blur near the lines, you'll find yourself with stuff on both sides. If you do not start close to the line that the shading will be not look right if the darker the shade needs to be close to the line. And that's where magic of clipping masks.

    And finally, here's an example of how I work with the script and the result:

    After that I drew a sketch, adjust the line widths and at the neatness I turn the paths to sketch the lines and then turn them into a live paint Group (which would ruin the line widths, unless you put the paths in first contour lines).

    With this live paint group need me a few minutes to color my piece dish. Then I develop the live paint group, in case of doubt, spend a few more minutes to make transparent traces of all regions, I need the shadow in one piece, and then I select all areas and use my script to activate the neat clipping masks. Then I can click on any field, enter the isolation mode, and go up one level, so I'm in the appropriate group, where I can shadow freely without the problem beyond the lines.

    At the end which allows me to apply shading complex and comprehensive, without wasting time to get there.

    PS: well, I just found out that draw inside is really close to what I want to do, and oddly enough, it produces the same Visual discrepancy with transparent traces that produces my script. I'll take a closer look that, while my script is a little more than just the stuff of clipping mask, so maybe I'll go for a hybrid solution. Everything that makes for a better workflow.

  • How to add several tracks with offset path?

    Hello

    I would like to create a script that can create multiple strokes with offset path (incremental or material (user will enter value))

    Is it possible to add several traces? I have found no examples in the script reference or elsewhere.

    Note: Mixtures does not give exactly the same results because sometimes especially when you are dealing with fonts outline paths is to be wrongly mixed a way.

    I'd be happy if someone give at least the main command loop.  I'll try to rest and will share here because I find the solution.

    Thank you

    Best regards.

    question.jpg

    OK, I'm going to assume your sub windows through the capture in the opening screen post.

    This is a completely different approach.

    This example uses executeMenuCommand so is only compatible with CS6 +.

    and Windows is only used from VB

    //-------------------------------------------------------------------
    
    // Offset Path in apperence panel
    
    // Script by Qwertyfly
    // contact [email protected]
    // version 0.1 beta
    
    //-------------------------------------------------------------------
    
    //number of offset paths
    var Qty = 5;
    
    //amount to offset
    var Offset = -5;
    
    //units to offest in
    var Unit = "px"; 
    
    //time to wait in milliseconds before sending keys.
    // more time is slower but more stable
    // I was able to run this with it set to 0, but a little bit of a pause is a good idea.
    var wait = 10;
    
    //-------------------------------------------------------------------
    function FillDialog_Windows(distance){
        var VB = [
            'WScript.Sleep ' + wait + '',
            'Set WshShell = WScript.CreateObject("WScript.Shell")',
            'WshShell.SendKeys "' + distance + '"',
            'WshShell.SendKeys "{ENTER}"'
            ].join('\n');
        var VBgo = new File('~/go.vbs');
        VBgo.open('w');
        VBgo.write(VB);
        VBgo.close();
        VBgo.execute();
    }
    function MakeStroke(offset){
        app.executeMenuCommand('Adobe New Stroke Shortcut');
        FillDialog_Windows(offset);
        app.executeMenuCommand('Live Offset Path');
    }
    
    for(var i = 1; i		   
  • How to add these symbols to Photoshop

    Hello

    I'm trying to add some texts to my image in photoshop and I would add symbols like those that I have attached here.

    Anyone know where to find and how to add them?

    Thank you

    Rose110ca

    symbols.jpg

    Short draw yourself, is to use brushes.

    Do a Google search on "Photoshop brush ornament.

    Some examples are HERE.

  • How to add a button with Javascript library

    Hello

    I am using Captivate 5.5 to create a template.

    In the files that will be created by using this template, we will add a button that executes a Javascript script. Now my question is, given that this button will be used across multiple slides in the file, I can add this button (with the Javascript code) to the library? We currently create manually everytime.

    We do not have a programmer on our team, so that we cannot create the widget. Is there another way?

    Thanks for your help.

    Anthony

    Why do you need to remove the slide?

    I have a white blank slide at the beginning of all my modules of Captivate. There are some issues that appear to be avoided if the first slide has nothing about it.  You don't have to do this very long slide.  Usually mine are just a second, in the long term.

  • How to play a clip with a tween animation

    I created a movie clip with symbol a tween animation and created an instance of the latter on the main stage. The animation is in the montage of film clip, not on the main timeline. I can't get the mc play using mc.play () or mc.gotoAndPlay.  What don't get me?

    Try to move the functions of activeCarton inside the function startButton.  The activeCarton object is not defined outside this function... speaking of which, you should always declare variables... change...

    activeCarton = storeCartons [myNumber];

    TO

    var activeCarton = storeCartons [myNumber];

  • Urgent: how to create a shortcut with a relative path?

    I put a set of files and folders nested on a server on a network location.  (Use of office machines Vista; I don't know that the server is running.  The files are a text file and two Office 2007 files).  Users will copy this set-up files on their computer (there is a program of VBA macro in a Word document, they need).  They need tomorrow (Friday) and the shortcut path gives me fits!

    The hierarchy looks like:

    MainDir
    File.txt
    SubDir1
    Shortcut to the Word file
    SubDir2
    Word file
    Excel file

    I don't think even the paths associated with the shortcut until I looked a little deeper.  Because I put all the files and folders together on my computer, when I did a drag - move in the folder on the server, the target properties and start in the shortcut always pointed at my computer!  So now, I'm afraid that a user copy this on their machine will have a shortcut that points to ~ my ~ computer, instead of the file on their computer.

    I deleted the shortcut located on the server and creates a new one from the Word file in the directory on the server.  Better - I think - but it still points to the location of the server.  And it is even more likely that, when the user opens the shortcut, it will try to open the file on the server, vice the file on their computer.

    How can I create a shortcut to this Word file that will pick up the relative path from around where to reside?  I can just click > properties and change the target and start in paths?  Or do I need a VBScript or VBA?

    I have to get this done fast!  A kick - in the right direction is greatly appreciated.

    Ed

    Hi Ed,

    It is not possible to create a shortcut with a relative path.

    You can try the following allows to bypass and check if it helps:

    Create a shortcut to cmd.exe running the start command to open the current directory. Then set the MDC in the

    The shortcut properties.

    a. make a new shortcut to: cmd.exe /c start.

    b. now right-click on it and get the properties of the shortcut (shortcut tab).

    c. the shortened full path must have been set to this:

    %windir%\system32\CMD.exe /c start.

    d. set the directory of "start in" (i.e. DLG) to be a relative path:

    (Example for a shortcut on the desktop)

    ...\SendTo

    e. click on "change icon...". "and set" look for icons in this file: "to: %SystemRoot%\system32\SHELL32.dll and press ENTER.

    Standard folder icon will probably be in the lower right.

    f. now you can copy this file and simply change the "start in:" to make new related shortcuts directory.

    NOTE: The above steps are just an example, so try this at your own risk. And check if it works.

    You can also read the following article and check:

    Folder redirection fails when you specify the mapped network drive or the Environment Variable

    http://support.Microsoft.com/kb/321805

    You can check out the following link and also post your request in the Technet forum for further assistance:

    http://social.technet.Microsoft.com/forums/en-us/winserverPN/threads

    Hope this information is useful.

  • How to add the style of java script?

    I would add some kind of alert style to this java script so that if 'required' fields are not informed or selected when the form is submitted, this part of the form is alerted with a red star like that, *

    I put one of the fields below with the relevant java script. Can someone please help me achieve this?


    < select name = "figure" class = "productButton" id = "figure" >

    < option value = "0" > - Select model - < / option >

    < option value = '7031' > Tropical Green Granite with bronze figurine sacred heart as on the photo (& pound; 7031) < / option >

    < option value = '5216' > Tropical Green Granite with bronze effect figure Sacred Heart (& pound; 5216) < / option >

    < option value = '5216' > Tropical Green Granite with figurine restored MF122 (& pound; 5216) < / option >

    < / select >


    <!-VALIDATE-> ORDER FORM

    < script type = "text/javascript" >

    <!--

    function RequiredFormFields() {}

    inform the customer to provide choices of figurine

    var model = document.forms.product.figurine.value;

    If (document.forms.product.figurine.selectedIndex == 0)

    {

    Alert ("Please indicate choice of miniature");

    Returns false;

    }

    } / / end of function

    ->

    < /script >


    OK, it's a bit more complicated but here go us:

    
    
    
    Test
    
    
    
        
        

    Characters remaining:

    You cannot type anything beyond the characters. Note If you select the first entry in the drop-down list, nothing happens? Because the number of characters of registration exceeds the character max relies on its own

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • How to create a group using photoshop scripts?

    Hey guys,.

    I can create a layer easily with the following code.

    But how do I create a group that contains more than one layer.

    docRef var = app.documents.add ();

    myLayer var = docRef.artLayers.add ();


    Here is an example...

    var doc = app.documents.add();
    var newLayerSet = doc.layerSets.add();
    var myLayer = doc.artLayers.add();
    var myLayer2 = doc.artLayers.add();
    //move the layers into the layerset
    myLayer.move(newLayerSet, ElementPlacement.INSIDE);
    myLayer2.move(newLayerSet, ElementPlacement.INSIDE);
    
  • How to add a filter with a report field

    Hello, I'm running Apex 3.x and I currently have in production, a standard report page with the following columns:

    Grant #, name of the grant, project #, name of the project, project exercise, #, name of the task in the task

    A grant may have many projects and a project can have many tasks.

    I was asked to add a "filter by: ' act as a selection list, with just these field values: show all, show of the projects and tasks, projects show

    If "Show all" is checked, the report remains the same and displays all the column headers and the data for all of the above fields.
    If "Show the projects and tasks" is selected, I refresh the page and display only the data (and the column headers) for project, the project name, project exercise, #, name of the task in the task.
    If "Show projects" is selected, I refresh the page and display only the data (and the column headers) for #, name of the project, project of the financial year of the project

    Could help you please direct me on how can I do to hide these other columns and data if "Show all" is not selected.

    Thank you very much
    Laura

    Create a selection with these 3 values (and do a select with submit), then in the attributes of your report, go to conditional columns you have and as a result, the condition of game ex: for example:

    Task column # > edit > status > expression PLSQL
    : PX_FILTER! = "Show projects".

    Where PX_FILTER is the new selection list that will allow you to create...

    Hope this helps,
    Sam

  • Does anyone know how to add a folder with sample data the installer to labview

    I have set up a program to install the application to a project I'm working on that.  I want to add a folder to the installation with some sample data files.  Currently, I added a readme file that tells the user to decompress a file included with the Setup program in a certain folder.  Is there a way to automate the process and include this with the installer?

    First add all the files you want to include in the project. Then in the properties of the installer:

    1 use tab destinations to add a folder if you have the sample files contained in their own folder.

    2. on the file source page, expand "My Computer" and find the files in the project you want to add.

    3. Select the folder you want to that they be located on the right side and click the right arrow.

  • How to read video clips with LabVIEW in Windows 7?

    I already had the opportunity to play a video clip of my LabVIEW program.  Now, with the same program in the two operating systems, Windows XP and Windows 7, both versions work, but the version of Windows 7 will not be saved.  Trying to save it, I get the following error message: "generic error of LabVIEW.  Cannot save VI... LabVIEW Save 3 error code: FP bunch. "A 2010 version with this problem sampling program is attached. Any help would be appreciated.

    Try this VI.

    It seems that you have a video ActiveX component is corrupted.

  • How to add code affiliated with the Web site created in Muse

    Can someone guide me... . How do I add the code to the Web site created in adobe affiliate marketing muse.

    Hello

    Place the code in the HTML body (I mean within the page) you can use the object > insert HTML code.

    If you want the code to be in the head section just right click on the page > go to the properties of the page > metadata > and paste the HTML code for the head.

    Kind regards

    Ankush

  • How to export a clip with an image set as thumbnail

    Im trying to export a clip to a friend, but they need to have a special sticker from the video. I need to do in PP video during export. How is that possible?

    Alas not this feature. Cannot be done.

    Feature request/Bug Report Form

Maybe you are looking for

  • x 1 carbon button mute does not work

    Hi, the microphone mute button does not work, or it lights up at all... the works of button mute speaker. Also, the Lenovo button next to it USED to work and now does not work for some reason. I have a new x 1 carbon with windows 8.1 and really need

  • scanning Windows 8.1 C5200

    I have Windows 8.1 (I'm so lucky) and I can't scan anything of my HP Photosmart C5200 all-in-One. Why do I need or how I can do?

  • I need new system drivers, but I can't connect to internet

    Original title; I guess I need a driver Just had to use the recovery disk Home 32 bit vista on a few years lenovo. Now, I can not connect to the internet, same cable. Where I would get the necessary driver to do so that I can burn to a disc and insta

  • Internet explorer on the start page

    Hello! Someone or something to remove internet explore from beginning. How can I get that back?

  • I do sort of the 8.2

    8.2 update. It loads the project, and then one to three minutes later, I get a windows error message... "unknown problem" and it crashes.Two sessions with the support resulted with me being able to run 8.1 successfully, but of course I can't open my