Turning greyscale alphas into group masks

Hi
I'm new to ps scripting and could do with a little help. I want to take a folder of greyscale alpha files and turn them into a single psd where each alpha layer is converted into a group mask with the filename as the group name. The script below is one I found at ps scripts and modified slightly. It works ok but turns the alpha layers into layer masks as opposed to group masks. If anyone can help me achieve this or point me in the direction of other codes that create groups and apply masks that I can study I would be really grateful.
var baseDoc = app.activeDocument;
var baseLayer = baseDoc.activeLayer;
var baseDocFolder = Folder(baseDoc.path);
var alphaSaveFolder = new Folder(baseDocFolder+'/fromAlphas');
if(!alphaSaveFolder.exists) alphaSaveFolder.create();
var alphaFolder = baseDocFolder.selectDlg('Select the aplha folder');
var alphaFiles = alphaFolder.getFiles(IsFileOneOfThese(['PSD','TIF','JPG']));// edit arguements to match your alpha files extension
for(var a = 0; a < alphaFiles.length; a++ ){
   var alpha = app.open(alphaFiles[a]);
   var alphaName = alpha.name.match(/(.*)(\.[^\.]+)/)[1];
   var tempAlpha = alpha.channels[0].duplicate(baseDoc);
   alpha.close(SaveOptions.DONOTSAVECHANGES);
  // var newLayer = baseLayer.duplicate(); Old duplicate string
   var newLayer = baseDoc.artLayers.add();
   newLayer.name = alphaName;
   baseDoc.activeLayer = newLayer;
   createChannelMask();
   applyAlphaAsMask( tempAlpha );
   deleteChannelMask(true);
   tempAlpha.remove();
function createChannelMask() {
   var desc = new ActionDescriptor();
    desc.putClass( charIDToTypeID('Nw  '), charIDToTypeID('Chnl') );
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
    desc.putReference( charIDToTypeID('At  '), ref );
    desc.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('UsrM'), charIDToTypeID('RvlA') );
    executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );
function applyAlphaAsMask( alpha ) {
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
    desc.putReference( charIDToTypeID('null'), ref );
    desc.putBoolean( charIDToTypeID('MkVs'), false );
    executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
    var desc = new ActionDescriptor();
        var desc1 = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putName( charIDToTypeID('Chnl'), alpha.name );
        desc1.putReference( charIDToTypeID('T   '), ref );
        desc1.putBoolean( charIDToTypeID('PrsT'), true );
    desc.putObject( charIDToTypeID('With'), charIDToTypeID('Clcl'), desc1 );
    executeAction( charIDToTypeID('AppI'), desc, DialogModes.NO );
    //selectComponetChannel();
function deleteChannelMask(apply){
   var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putEnumerated(charIDToTypeID("Chnl"), charIDToTypeID("Chnl"), charIDToTypeID("Msk "));
    desc.putReference(charIDToTypeID("null"), ref);
function newDocFromLayer(docName,layerName){
   docName == undefined ? docName = "Untitled":docName;
   layerName == undefined ? layerName = activeDocument.activeLayer.name:layerName;
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putClass( charIDToTypeID( "Dcmn" ) );
    desc.putReference( charIDToTypeID( "null" ), ref );
    desc.putString( charIDToTypeID( "Nm  " ), docName );
       var ref1 = new ActionReference();
        ref1.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
    desc.putReference( charIDToTypeID( "Usng" ), ref1 );
    desc.putString( charIDToTypeID( "LyrN" ), layerName );
   executeAction( charIDToTypeID( "Mk  " ), desc, DialogModes.NO );
   return app.activeDocument;
// from Image Processor.jsx
// given a file name and a list of extensions
// determine if this file is in the list of extensions
function IsFileOneOfThese( inFileName, inArrayOfFileExtensions ) {
   var lastDot = inFileName.toString().lastIndexOf( "." );
   if ( lastDot == -1 ) {
      return false;
   var strLength = inFileName.toString().length;
   var extension = inFileName.toString().substr( lastDot + 1, strLength - lastDot );
   extension = extension.toUpperCase();
   for (var i = 0; i < inArrayOfFileExtensions.length; i++ ) {
      if ( extension == inArrayOfFileExtensions[i] ) {
         return true;
   return false;

Do you mean clipping group or layerSet? If you mean layerSet then if I understand what you want replace
var newLayer = baseDoc.artLayers.add();// adds a layer
with
var newLayer = baseDoc.layerSets.add();// add a layer set(group)

Similar Messages

  • How do I turn a shape layer into a mask in After Effects?

    How do I turn a shape layer into a mask in After Effects?

    I should also mention that if you create the shape with any of the shape tools (rectangle, Polly star, eclipse) instead of the pen tool you will have to convert the shape to a bezier path before you can copy the path and paste it to a mask. Easy to do if you have the recent version of AE, not so easy if you're using an older version.
    when you have trouble figuring things out simply type something like track matte in the Search After Effects help field at the top right corner of the AE application frame. You will get these resources: http://www.adobe.com/cfusion/search/index.cfm?cat=support&term=Track%20matte&loc=en_US&sel f=1&lr=en_US&site=aftereffects…

  • Moving a layer's alpha channel into layer mask

    (CS3)
    I have a raster layer that has some semi-transparent pixels. I'd like to make the layer itself fully opaque, and move the contents of its alpha channel into a layer mask. How would I go about doing this? (If possible, merging the alpha channel with what I have already placed into the layer mask.)
    Thanks!

    kopo88 wrote:
    (CS3)
    I have a raster layer that has some semi-transparent pixels. I'd like to make the layer itself fully opaque, and move the contents of its alpha channel into a layer mask. How would I go about doing this? (If possible, merging the alpha channel with what I have already placed into the layer mask.)
    Thanks!
    Copy the alpha channel into your clipboard, then paste it into the mask. To paste into a layer's mask, alt click the mask to make the mask the focus then ctrl v to paste. To remove focus, alt click on the mask again or click on another layer. As to how to mix the two, you could probably do it using calculations.

  • Why are my texts getting sent back to me and turned into group messages?

    I had an ongoing conversation with someone. There weren't any problems. I sent myself a picture from my laptop to myself in iMessage. When I looked at my phone, it displayed 3 different conversations with my name as the name. I noticed that the last thing I had said to the other person was the message preview for one of my names so it was as if somehow my conversation replaced his. I clicked it open and it appeared to be blank so I deleted it.
    I went to send him a text from the new message thing, but when i would send a text to his phone number, it would automatically be sent to me instead and open my name's conversation again.
    When I looked at the conversation with him on my laptop in iMessage, the history was all still there, so I tried to send him a message from my laptop and it would display that the message was not sent. Except though it didn't send to him, it did send back to myself again. This time even using his ringtone that I have only for him. I restarted my phone to see if this would fix the problem. When I turned my phone on, it was back to normal with his conversation and all of its history, but when i tried to send him a text again, it turned the conversation into a group message with him, and myself? I'm very confused and I don't know how to fix this. Can anyone help with this problem? I tried searching the internet for people with similar problems and couldn't find anything. :I
    Thank you.

    If you're exchanging texts with someone who has a basic phone, messages they send to you will be broken up into blocks no larger than 160 characters. They wil also receive your messages broken up in the blocks not larger than 160 characters.

  • How do I remove Facebook contacts from my Contacts list on my 4S???  I've already gone into iCloud settings and Facebook is not even an option to turn off and I've gone into "Groups" in my contact list and Facebook is not there either.  How do I stop this

    How do I remove Facebook contacts from my Contacts list on my 4S???  I've already gone into iCloud settings and Facebook is not even an option to turn off and I've gone into "Groups" in my contact list and Facebook is not there either.  How do I stop this??

    Hmmmm...maybe try deleting them again (I know it's a pain) and then doing a manual icloud backup (unless you already did this). Icloud may be putting them back on there. I never allowed FB to put the contacts on my phone lol. Also try going into Privacy and Contacts...make sure FB isn't on in there. Might be a few other spots to check under settings to make sure too. And...you might want to try deleting the FB app, do a icloud backup, and then reinstall FB

  • How do I turn an image into a transparency?

    Hi,
    There's a question I've seen asked dozens or hundreds of times, and I thought I found an answer a few years ago. I've since forgotten how to do it:
    Turn an image into a transparency.
    Now, the obvious solution is to set the layer to "multiply." Yes, this is the effect I want. However, I want the layer to be transparent instead.
    Another solution is to draw an image on a transparent layer. This works great, but only applies if I create the image from scratch. I want to convert an existing image.
    Another solution is multiple steps:
    1) Copy image
    2) Click "edit in quick mask mode."
    3) Paste image
    4) Exit quick mask mode.
    5) Invert selection.
    6) Ctrl+backspace to fill selection with black, on a blank transparent layer.
    Result? The image is now transparent! However, this converts the image to greyscale! Great for linework and text, terrible for photos or art!
    In an older version of Photoshop 7, I believe I got the following to work:
    A) Follow the previous steps 1-6, creating a layer with transparency
    B) Copy the original picture to a layer above the transparency
    C) Group the layer with the transparency layer below. (Note, grouping doesn't work the same any more.)
    D) The top layer provides the colors, but the bottom layer provides the transparency.
    E) It is too light, so you take the top layer, and maximize "saturation" 100%.
    F) Merge the two layers. It retains the transparency of the bottom layer, with the hue of the top layer.
    This no longer works, because I don't know how grouping layers works anymore.
    So, I need white pixels to be transparent. Black pixels to have zero transparency. Red pixels to have zero transparency. Etc.
    Meanwhile, grey pixels are solid black, but partly transparent. Pink pixels are solid red, but partly transparent.
    All pixels are 100% saturated, and the "lightness" is determined by how transparent they are.
    So, an analogy would be printing a photo on a transparency. I need to convert an image to a transparency.
    If the image/layer were overlaid on white, it would look exactly like the original photo.
    Does anyone know how to accomplish this? Mathematically, it's easy. But I don't know about any filter, process, or method to make the conversion using CS5.
    Thanks,
    Ben

    Hello!
    I hope that I understand what you need.
    (One could just put the image on a layer, and lower its opacity, but you seem to be looking for an effect in wich the tranparency is not the same for all pixels.)
    Try this:
    1) Turn your image image as a layer (double-click it if it is a background layer) [In order to add a mask]
    2) Select all, Copy (CTRL+a, CTRL+C)
    3) add a layer mask (click the rectangle with a circle in the bottom of the layers panel) [to be able to change transparency]
    4) target the mask [so that you can past an image in it] ALT+click the mask, paste the image.
    5) Invert the colors of the mask (CTRL+I) [in order for the white to be transparent and the black opaque].
    You now have a layer whose transparency is based on the lightness of the pixels.
    Hope that's what you are after!
    Pierre

  • What peripherals do you need to turn your iPhone into a conference room speakerphone?

    What peripherals do you need to turn your iPhone into a conference room speakerphone system?
    If you buy a separate conference mic and a speaker, can they somehow work together off the iPhone headphone jack like a huge set of group earphones?  What if you want to connect 2 mics and a speaker?
    Do you have to be very careful that they can all be attached somehow at the same time?
    Are there reasonably priced conference room speakerphone peripherals the work well together that you would recommend?
    Steve

    Why don't you contact Apple and find out?  Certainly if you can find your way around the internet to have been able to find this forum, you can certainly find the number for AppleCare.

  • Can I turn greenscreen video into video with transparent background (instead of default black backgr

    Can I turn greenscreen video into video with transparent background to  overlay on another video in another program.  probably export as avi.     I know I can in after effects  but comfortable with premiere.   basically want to turn the greenscreen from a black to transparent background  ppro cs6     windows
    [ email address removed by forum host ]

    Harm is correct. It would be better to edit in the program where you keyed out the green. However, if you really must ...
    DPX is one file per frame. While you may not be able to open it from Windows, it is only because Windwos has not been told to open them in Photoshop.
    The whole point of the DPX file is to have a visually lossless storage of your frames that is designed to be used between applications (just what you want to do): http://en.wikipedia.org/wiki/Digital_Picture_Exchange
    However, if you prefer to use another option that you are more comfortable with, you can use PNG.
    Or...
    If you insist on a single video, use the Animation codec for Quicktime.
    In any case, you need a picture format or video CODEC that can store an Alpha Channel.
    Or.....
    Export the video with the black and use a Luma key in the next application.
    Or ...
    Export the video with the black, and then export a video of just the alpha channel as a blabk and white image where black is transparent when used as a track matte, and then in the next application use the video of the alpha channel as a track matte.
    Since you haven't said what the other application is or why you want to use it, we are having a little trouble offering a specific solution.

  • Where can I get a Lightroom preset that turns a portrait into a sketch?

    Where can I find a Lightroom that turns a portrait into a sketch?

    If Photoshop or Photoshop Elements is installed, LR can pass an image to that directly; but any other application or standalone utility that you use to carry out a job like this, can be set up as a named "external editor" preset. This gives equally easy access from inside LR. You don't need to Export a copy, start a program, find and open the image; nor, then import the results back to LR - these steps are all automated for you.
    You right-click on an image and select your editing preset in the context menu; LR saves a copy of your current image and opens it into the other program. You complete the task there, Save and close. LR now (all by itself) shows two versions of that image - the one you saw before, and a new one which shows the results of your external edit.
    So even though LR is not in fact doing the task, but subcontracting it out - it is still just about as convenient for the user, as it would be if this were a true LR extension / plugin.
    Some Photoshop plugins come in a standalone version as well, and in that case, the standalone app can be used as a targeted editor by LR, which may be faster and simpler. However if you do use such a plugin (or technique using standard tools) within PS, or other full-featured image editor, you have a full range of other editing possibilities there at the same time; for example, so you can mask and vary the strength of your "sketch" effect across different parts of the photo.

  • Need to cut into a mask to reveal layer

    I need to cut into a mask to reveal a layer. I have a alpha image with thousands of lights scattered around the image. I'm laying the lights layer over an image of a city to create more lights in various buildings. All I need to do is create some form of mask that when I cut into it reveals the lights below which is over the city. It's a basic question but I'm stumped. Thanks peeps.

    Just target the upper layer's layer mask and set your paint brush to a good size black paint and paint the area you want the light to show through from the lower layer.  Black will make the current top layer's opacity transparent in the areas you paint over.

  • What is the best way to turn line art into a 3D image in Illustrator? Thanks for your help.

    What is the best way to turn line art into a 3D image in Illustrator? Thanks for your help.

    What version of Illustrator? What do you mean by "Line Art"? What do you mean by "3d image"? Post images showing your starting artwork and an example of what you are trying to achieve.
    If you have Illustrator 12 or higher you can extrude or lathe a simple group or path using Effects > 3D > [Pick one]. You must start with vector data, not a placed raster image. You are very limited in what you can do, and you cannot model multiple objects within one 3D world. Each object you extrude/revolve/rotate is its own world, with its own perspective and camera. You can also make any art into a Symbol, then map that symbol onto any 3D surface you create. The results are, at best, acceptable, and often total garbage.

  • How can I see in my address book all contaacts that have not been placed into groups?

    How can I see in my address book the contacts that have not been put into groups?

    The best way to do that is create a new "smart group" with the following:
    This way you can identify those without a group and drag them to one.
    Regards,
    Captfred

  • How do you get your contacts into groups?

    how do you get your contacts into groups?

    When you ask a question, please include the version of Mac OS X on your computer. iOS is not a Mac operating system.
    Assuming you are running OS 10.9.1:
    Open Contacts. Click File in the menu bar and select New Group. Enter the name of the group in Contacts on the left.
    Go back to All Contacts (on the left) then drag and drop the names you want in that group on to the folder you just named.
    Repeat as necessary for other groups.
    Note that the names remain, as they should, in All Contacts, even after you have added them to a group.. You can delete a group if you want. The names will still remain in All Contacts.

  • Turn a script into an .exe file?

    Hi,
    How can I turn a JavaScript into an .exe file (on Windows)? The
    advantage is that if the script uses only ScriptUI features, it will
    never need to launch InDesign. Additionally, it is possible to package
    it that way with a special icon that appears if it is placed on the
    desktop, and when it runs the icon appears in the taskbar.
    An example of what I'd look to achieve is the hyphenchecker script,
    written by the late Teus de Jong. There is one Windows-only version
    available on his website (which is still being maintained, probably by
    his son) which is an .exe file -- precisely what I'm trying to do.
    Thanks,
    Ariel

    straight form javascript i don't think there is a way.
    however you can use, i think, Visual Basic (not vbScript!!) as a wrapper for js (using doScript)?

  • Mail turns PDF attachment into jepg

    I use distiller and acrobat to create PDFs from Quark documents; for the last few days, attaching a new PDF to an email in Mail has turned the PDF into a jpeg which PC users can't open. The problem has just cleared itself (without me knowingly doing anything) but it has happened before and I guess may happen again. Any idea of the cause and solution?

    What I should have said is Apple should not make the Image Size adjustment an available option when a PDF file is attached to a message.
    Yes, this is the answer. Using the term seemed to happen - it either happens or it doesn't but Mail will not and cannot change the file type or the file extension for an attached file without user intervention. Using the Image Size adjustment for a single page PDF file which appears inline or viewed in place within the body of the message does change the file type or file extension for the file from .pdf to .jpg since the Image Size adjustment is intended and can only be used for picture or image file attachments, not with PDF files.

Maybe you are looking for