Unlocking Background Layer with lots of other layers

I've been looking at the similar questions, but no script has worked perfectly yet. I have a series of phoshop actions that I run on a regular basis. I have two version of each, one for if there's a locked background layer, and one for when its already been unlocked. Otherwise my actions error.
I'd like to simplify the process and have a script run that finds any locked layers (ie: background) and unlocks it, even if there are 15 other layers and even if I have another layer selected. It should also run without errors if there are no locked (background) layers to be found.
I don't know the first thing about writing my own scripts, so can somebody tell me what lines of code I'd need? Thank you Thank you!

function makeActiveByIndex( index, visible ){
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putIndex(charIDToTypeID( 'Lyr ' ), index )
    desc.putReference( charIDToTypeID( 'null' ), ref );
    desc.putBoolean( charIDToTypeID( 'MkVs' ), visible );
    executeAction( charIDToTypeID( 'slct' ), desc, DialogModes.NO );   
function getNumberOfLayers(){
    var ref = new ActionReference();
    ref.putProperty( charIDToTypeID( 'Prpr' ), charIDToTypeID( 'NmbL' ) );
    ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID( 'Ordn' ), charIDToTypeID( 'Trgt' ) );
    return executeActionGet( ref ).getInteger( charIDToTypeID( 'NmbL' )) ;
function getProperty( psClass, psKey, index ){// integer:Class, integer:key
    var ref = new ActionReference();
    if( psKey != undefined ) ref.putProperty( charIDToTypeID( "Prpr" ), psKey );
    if(index != undefined ){
        ref.putIndex( psClass, index );
    }else{
        ref.putEnumerated( psClass , charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
    try{
        var desc = executeActionGet(ref);
    }catch(e){ return; }// return on error
    if(desc.count == 0) return;// return undefined if property doesn't exists
    var dataType = desc.getType(psKey);
    switch(dataType){// not all types supported - returns undefined if not supported
        case DescValueType.INTEGERTYPE:
            return desc.getInteger(psKey);
            break;
        case DescValueType.ALIASTYPE:
            return desc.getPath(psKey);
            break;
        case DescValueType.BOOLEANTYPE:
            return desc.getBoolean(psKey);
            break;
        case DescValueType.BOOLEANTYPE:
            return desc.getBoolean(psKey);
            break;
        case DescValueType.UNITDOUBLE:
            return desc.getUnitDoubleValue(psKey);
            break;
        case DescValueType.STRINGTYPE:
            return desc.getString(psKey);
            break;
        case  DescValueType.OBJECTTYPE:
            return desc.getObjectValue(psKey);
            break;
        case  DescValueType.LISTTYPE:
            return desc.getList(psKey);
            break;
        case  DescValueType.ENUMERATEDTYPE:
            return desc.getEnumerationValue(psKey);
            break;
var doc = app.activeDocument;
var layerCount = getNumberOfLayers();
var invisibleLayers = [];
var loopStart = Number(!doc.layers[doc.layers.length-1].isBackgroundLayer);
for(var layerIndex = loopStart;layerIndex<=layerCount;layerIndex++){
    if(!getProperty( charIDToTypeID('Lyr '), stringIDToTypeID( 'visible' ), layerIndex )) invisibleLayers.push(layerIndex);
for(var hiddenIndex=0;hiddenIndex<invisibleLayers.length;hiddenIndex++){
    makeActiveByIndex( invisibleLayers[hiddenIndex], true);
    if(doc.activeLayer.allLocked) doc.activeLayer.allLocked = false;
    if(doc.activeLayer.pixelsLocked) doc.activeLayer.pixelsLocked = false;
    if(doc.activeLayer.positionLocked) doc.activeLayer.positionLocked = false;
    if(doc.activeLayer.transparentPixelsLocked) doc.activeLayer.transparentPixelsLocked = false;
    doc.activeLayer.visible =  false;

Similar Messages

  • How do I unlock background layer?

    How do I unlock the background layer on free trial photoshop?

    go to layers window and select the layer you are trying to unlock, There should be a lock icon next to name of layer, you can drag lock icon to trash can at the bottom of the layer window and layer will be unlocked. There is also a lock icon just above all the layers and you can toggle the layer as locked or unlocked. multiple ways to do the same task. Male sure to the select the correct layer you are trying to unlock. background layer applies as well.

  • Can't unlock background layer using Photoshop CS3 Extended

    I installed CS3 a few days ago (though I'm an experienced CS2 and Photoshop 6 user) and opened Photoshop CS3 Extended today for the first time.
    The problem I'm having is with unlocking the background layer. I read in the documentation and on the Net about double-clicking and renaming the layer (which is what I did in other versions), or creating a new file with a transparent background, but those things aren't working for me in this version.
    I opened a tiff file (a logo I want to use as the basis for a new image) but I can't unlock the background layer so I can copy, manipulate or add to it. Everything on the Layers drop-down menu is grayed out, as are the word Lock: and the symbols following it in the Layers window.
    I tried creating a new image but when File|New dialog box opens the option to use transparent in the Background Contents dropdown is grayed out, too.
    I'd appreciate some help with this.
    Thanks,
    Peggy

    The issue has to do with the mode that you are in.  If it is a TIFF or GIF file that you are opening, when you click on "Image -- Mode" you are likely to see "Indexed Color..." with a checkmark next to it.  Be sure to select "RGB Color."  Once you have done that, you can simply double-click the background layer in the layers palette to unlock the image.

  • Unlocking Background layer

    I am making a collage of pictures and realized I had added a number of pictures directly onto the background without creating separate layers. When I wanted to move some of them, I couldn't because the background is locked.Is there a way to unlock the background so I don't have to redo it?Abbey

    Abbey,
    To unlock the Background layer, simply double-click it and rename it to something other than "Background". The default name "Layer 0" is sufficient.
    But I'm a bit confused. You say you already added some items to the background? Since these are not layers I'm guessing they are permanent and unlocking the Background won't buy you anything.
    I find it good practice to first duplicate the Background layer, turn off it's visibility, and start working from the duplicate layer. This way the orignal will still be there in an emergency.

  • Unlock background layer

    How do I unlock the background layer without duplicating it first and deleting the locked layer. It's a nuisance. I never ever want that background layer locked. why is photoshop locking it by default?

    I have always wondered why they locked the initial layer. Many times I will open a picture to do alterations on it, and many times I have to unlock that layer, pretty much all the time actually. It is simple to promote to a regular layer, I just don't see the productivity enhancement in locking it.
    Many times a regular image you open will just have 1 layer, and the whole layer is the background layer. I agree that locking the "background" is a good idea, but not when an image is 99% of the time interpreted as a single layer, in the form of a locked background layer. Not that I'm sitting here day in and day out pulling my hair out over it, but it is slighty perplexing and slightly annoying, and I've always wanted to ask a Photoshop Guru the benefits of making this happen by default with no option to change it at all.

  • Newbie Question ... How do you Unlock Background Layer

    How do you unlock the background layer?  I put together an image then flattened it.  Now it is showing as locked.  I want to make changes to the various layers I used to make the image.  The lock symbol in ghosted, as well as the Lock Grid image.
    Can anyone offer any quick assistance?
    Thanks.

    You'll get better response on the Photoshop Elements forum for a Photoshop Elements question, of course.
    But, meantime, try double-clicking on the Background layer on the Layersa palette.

  • How do I make text fill an oval and then place behind a background layer with CSS

    Hi everyone,
    I created a framed oval picture as a background with drop shadow for my portfolio site.
    See:  www.adjacentdimensionsmedia.com
    Now I want to put text on a clear "glass window/png" that fills an oval that will go inside the frame and I would like it to slide up behind the black background frame, but on top of the image.
    I would like to move the scroll bar so that the text which will be about my services can slide up and fit the ovals you scroll down.
    I tried:
    div class= "circle"
    </div>
    .circle {
    shape-inside:
    polygon (0px 150px)
    and it didn't work.
    I thought I would use Z-axis to get it behind background but I am not sure if that will work.
    any thoughts?

    I had never heard of shape-inside before, so I did some poking around.
    Looks like shape-inside is an experimental feature with little to no browsers supporting it.
    On top of that, as far as I can tell from the documentation about it, a single set of coordinates with the polygon value won't do anything either way. You need at least 3 coordinates with polygon (making a triangle as the minimum). And that is only for the reflow of content, it has nothing to do with the actual shape of the element it's being used on.
    If done correctly, in combination with the border-radius attribute, one could create a circle with a container element, then theoretically use a many sided polygon with shape-inside to force the content of the circular container to take on a relatively circular flow (think octagon in a circle).
    I wasn't able to make any shape-inside settings work in any current browser though.
    EDIT: Actually, I was able to get it to work in Chrome, with the -webkit- prefix and a newly downloaded version of Opera using the standard nomenclature. Definitely not ready for prime time. For shape-outside testing anyway. Shape-inside I still can't get to function in either.

  • Photoshop file with lots of text layers for Final Cut

    I have created a photoshop file with around 20 different text layers. The sizing and the location of the layers is essential.
    When my editor imports the file the text layers lose their properties (sizing and placement).
    Is there something I should be doing to help solve this problem?
    Can you use text layers between photoshop and final cut?

    I would ask this in the 'Mac' side of the PS forum.

  • LAN DNS resolution has changed - along with lots of other behaviours

    Hi
    Last Friday I experienced a lot of strange network/firewall behaviour on my Macs, both running 10.6.7. I don't know what the problem is but am trying to isolate it - or them.
    Considering just the MacBook Pro, I have been running the same setup for over a year at different locations and never experienced this before. The MBP is named Isola, it runs Windows XP Pro on VMWare Fusion and MAMP as a development/test environment for websites.
    Since I have had this setup, with MAMP running and using the normal Apache and MySQL ports I could connect to websites using Mac browsers on: http://localhost/, if I was testing on Windows browsers I would use http://isola/
    This worked at home using an Airport connection over a Netgear modem/router:
    TCP/IP
    Using DHCP with manual address
    IPv4: 192.168.0.5
    Subnet Mask: 255.255.255.0
    Router: 192.168.0.1
    Configure IPv6: Automatically
    DNS Servers: 192.168.0.1
    Search Domains: -
    It also worked at the office - 2 Macs networked using a Netgear Gigabit switch, also connected to the building's ethernet system for external internet connection:
    TCP/IP
    Using DHCP
    IPv4: 10.0.21.10
    Subnet Mask: 255.255.255.0
    Router: 10.0.21.254
    Configure IPv6: Automatically
    DNS Servers: 10.0.21.254
    Search Domains: popcorn
    I have two Locations set up in networking preferences, Home and Office. DHCP and DNS at home are provided by my ISP I believe. Apparently the IT infrastructure in the building where my office is located handles the DHCP and DNS.
    Since last Friday when I try to connect to http://isola/ using a Windows browser the request either times out (Internet Explorer) or is re-routed to http://www.isola.com (Firefox and some other browsers). In order to the site on my MAMP server I have to use http://isola.local/
    I can replicate the same behaviour when trying to connect to the MAMP server using my Mac Pro.
    I have flushed both Macs' DNS caches, repaired permissions and tried other stuff which I can't quite remember now. Nothing has made any difference.
    I'd really like to know if this new behaviour is likely to be caused by my configuration or the office DNS setup and ideally get it back to what it was before.
    Yesterday I started experiencing strange behaviour with the MBP firewall. It may be part of the problem or not - I'll include for information. It has always been on and set up normally - none of the Advanced settings checked. There were a whole load of software listed in the Advanced tab such as Skype, Safari, Opera configured to accept incoming connections. Yesterday for the first time ever I had a whole load of firewall dialogue boxes open on start up asking to allow or block network connections to basic OS X services: AppleFileServer, cups-lpd, cupsd, httpd, krb5kdc, mysqld, nmbd, smbd, vmnet-natd. I think some of these are due to File Sharing and Printer Sharing being enabled in the Sharing Preferences - but they've been enabled for over a year.
    Thanks in advance for any advice.

    Safari gives the error message
    Safari can't open the page "[URL]" because your computer isn't connected to the Internet.
    on any attempt to access a page by URL. If I put in an IP address it loads fine (aside from not being able to resolve any links to images, etc. which are linked using a domain name).
    nslookup google.com on the command line gives the error:
    /SourceCache/bind9/bind9-31/bind9/lib/isc/unix/socket.c:4525: bind: No route to host
    nslookup: isc_socket_bind: unexpected error
    DNS resolution does not work on Firefox either.
    All checkboxes in the System Preferences>Network>Advanced>Proxies tab are unchecked. The box at the bottom ("Bypass proxy settings...") contains:
    *.local, 169.254/16
    Thanks for trying to help me out! I'm happy to provide any other information that might be useful to you.

  • Can not attach documents or files to email along with lots of other problems

    I can not attach any files or documents to an email. I am working on a Mac OS10.4. Have tried doing the F9 button as suggested in the help section and it totally froze my computer up to the point of having to unplug it and start my whole computer up. Also we can not finishing downloading Firefox 3.6.13

    Who will answer my question? and when?

  • Why does the Background Layer unlock itself?

    When I open a picture in PS the first layer is a locked background layer. If I start working in PS it changes automatically to an unlocked Layer 0. I want it to stay as an locked background layer. I have used PS for a few years, and just started happening.

    With the new version of Photoshop if you work on the background layer and do something like click on the add layer mask icon in the layer palette. Since the background layer does not support transparency Photoshop knows you need to convert the background layer to a normal layer so Photoshop automatically does that for you.  If you just paint on the background layer or clear or fill an area, stroke a selection it will remain a background layer  with its transparency locked.  The Background layer is only partially locked so you can work on it as shown by the un-filled in lock icon on the background layer in the layer palette.  If you look here you see layer 2 is unlocked, Layer 1 is fully locked and the background layer is partly locked and has been worked on.

  • Advice when using lots of Adjustment Layers/Layer Masks

    I want to create an image that will be composed of lots of layer masks that I am going to use to paint different effects back over someone's face. I currently have a hue/saturation adjustment layer that I used to desaturate the image and then I selectively painted that desaturated layer back over the skin of someone, I also want to add some green so I created a color balance layer and made a layer mask out of it and want to selectively paint back some green to the skin tone.
    1. Does it matter in the layer stacking order where these adjustment layers/layer masks reside?
    2. Any general tips for working with an image with lots of adjustment layers/layer masks?
    Thanks.

    Depending upon the blend mode, it does matter what order you put the layers, as the topmost layer will affect what's below it.  You can play around with the different postions and see what works best for your image.  You can also group the layers, and set the blend mode of the group to anything other than "Pass Through", so that the adjustment layers only affect what's in the group.

  • Photoshop painfully slow with lots of layers.

    I've seen this before with Photoshop. I have a pretty tame PSD file, 35mb. Web design file with lots of small layers. Photoshop will go from 20% to 105% in Apple's Activity Monitor—and I'm not doing anything in Photoshop. If I try to move a single type layer with the cursor keys, for example, I get the move dialog with a progress bar. Very unresponsive overall.
    I'm about to make smart objects of all my layer grous, and see if this helps, but this is a file I've worked on in the past, and photoshop was very responsive.
    Larger MB files with big images seem fine.
    Details:
    Photoshop 13.0.4
    OS X 10.8.3
    Freshly wiped drive with new install of OS X and CS6.
    Macbook Pro 2010, 8gb ram, 500gb, 7200 drive.
    Recently just reset PRAM, Booted in SAFE mode, reset the Macs SMC.
    Ideas?

    Maybe you should check out this
    http://helpx.adobe.com/photoshop/kb/troubleshoot-fonts-photoshop-cs5.html
    No idea if it might help, but as you mentioned text layers …

  • I have several layers for this image: Background, Moon, Tree, Grass and Clouds.  When I try to use the Move tool to move the Moon, the tool jumps to the Tree layer.  The same thing happens with the other layers as well (except the background layer).  How

    I have several layers for my image: Background, Moon, Tree, Grass and Clouds.  When I try to use the Move tool to move the Moon, the tool jumps to the Tree layer.  The same thing happens with the other layers as well (except the background layer).  How can I keep the move tool from jumpimg to the Tree layer?

    1. Pre-select (highlight) the layer to move in the Layers panel.  or-
    2. [ALT+Right mouse click]  to select the wanted layer in the image window.
    and maybe
    3. Set the PS option to "Auto-select" a layer with cursor hover.  (can be very confusing!)

  • Using Javascript to rasterize a layer and maintain its position with other layers.

    Trying to use javascript to rasterize just the contents of a certain layer by its name.
    It needs to maintain its position.
    I've sort of cobbled a script, but it keeps moving the rastered art to the top layer.
    Ex, top down i have Layer 4, RasterizeMe, Layer 2, Layer 1. 
    The rastered contents end up on Layer 4
    Any help would be apprecieated, or if theres a better method of doing this.
    //  Rasterize Layer by name
        if ( app.documents.length > 0 ) {
            doc = app.activeDocument;
            if(!doc.saved){
                Window.alert("This script needs to modify your document. Please save it before running this script.");
            }else{
                createRasterLayer(doc);
        }else{
            Window.alert("You must open at least one document.");
    function createRasterLayer(doc){
        var totalLayers = doc.layers.length;  //get the total number of layers in the active document
        for ( var i = 0 ; i < totalLayers ; i++){  //looping through layers            
            var currentLayer = doc.layers[i];
            var tempItem;
            if(currentLayer.visible == false) continue;   //We don't want to deal with hidden layers
            currentLayer.locked = false;                       //Unlock the layer if needed
            var layerName = new String( currentLayer.name );
            if ( layerName.indexOf("RasterizeMe") == 0 ) {
                currentLayer.hasSelectedArtwork = true;   //Select ALL in the layer
                if(doc.visibleBounds[2] == 0) continue;   // ignore empty layers
                var newoptions = new RasterizeOptions; 
                newoptions.resolution = 350;
                if ( doc.selection.length > 0 ) {
                    newGroup = app.activeDocument.groupItems.add();
                    for ( z = 0; z < doc.selection.length; z++ ) {
                        doc.selection[z].move( newGroup, ElementPlacement.INSIDE);
                    doc.rasterize (newGroup, newGroup.visibleBounds, newoptions);

    you're adding the group to the document, it will be the top most object on the top most layer
    newGroup = app.activeDocument.groupItems.add();
    use this to add the group to the current layer
    newGroup = currentLayer.groupItems.add();
    or if theres a better method of doing this.
    I would
    - loop through all layers,
    - hide them all, except the one you want to rasterize,
    - Rasterize the document
    - unhide layers

Maybe you are looking for

  • Apple TV 2 Waiting for network services, unable to sign in to iTunes store

    Received my Apple TV yesterday. It is connected to my network (I have tried wired and wireless). I can view movie previews and Podcasts. I cannot sign in to the iTunes Store (therefore cant rent movies), cannot view Youtube videos (No content availab

  • URGENT HELP in PAGES '09!

    So I have been working a lab report for the past week, have it completely typed and realized I need a title page. If it were a printed hard copy that needed to be handed in, I realize I could just print seperately, but this document is to be submitte

  • When jpg-files are opened in CR first, they are quite ok in CR, but when they

    are opened to PS6 afterwards, they are not displayed as they are, only big coloured quarters appear, it looks like immense pixels. What's wrong? Thanks, Kathy

  • Where can I modify the content of #BOX_BODY#

    Hi, when I run my page, the #BOX_BODY# code is translated if you view it by viewing the source of html page. It creates a table(<table width="100">...) I'd like to modify the cellpadding and cellspacing of that dynamique table. I've checked the templ

  • Ultraslim wireless keyboard shift key stick

    I have an Ultraslim Wireles Keyboard and Mouse combo, but whenever I hit the shift key it stays registered for sometime. To type in passwords with capitals I have to wait a second or two after hitting the shift to get the right input. Is there anyway