Photoshop CS6 using javaScript to truncate alpha channel name

Hello,
I'm a production artist and I work with PSD files that were created in Adobe Scene7 Image Authoring Tool. These PSDs contain a background layer along with 1-20 alpha channels. My script has to make a new blank layer for every alpha channel in the document. Then it fills the new layer with light gray. So far, my code accomplishes this. However, I'd like to apply the name of the alpha channel to the layer, but I need the name to be truncated. Every alpha channel starts with one or more characters followed by a backslash and then finishes with one or more characters. Here's an example:
An alpha channel might be named:  Floor\floor
In this example I need my layer name to be just:  floor. This means all character to the left of the backslash, including the backslash itself needs to be discarded. I was using the subSring() statement to do this. When I try to step through the code, line by line in ExtendScript, I immediately get an error that says Unterminated String Constant and Line 31 of my code is highlighted. I suspect it doesn't like the way I wrote the backslash character, although I surrounded it in double quotes to define it as a string.
Can anyone tell me why I'm getting this error?
Below is my code with lots of comments to walk you through the process. I wrote where the error occurs in red type.
I'm new to JavaScript so I'm not sure my while loop is accurate.
#target photoshop
// The #target photoshop makes the script run in PS.
// declare variable to contain the active document
var myDoc=app.activeDocument;
// declare variable to contain the number of alpha channels, excluding the RGB channels
var alphaChan = myDoc.channels.length - 3;
alert(alphaChan + " alpha channels exist");
// create loop to make new layers based on number of alpha channels, fill layer with gray and apply alpha channel name to new layer
for (a=0 ; a<alphaChan ; a+=1){
// make new blank layer
myDoc.artLayers.add();
// fill blank layer with gray
var color = new SolidColor();
color.rgb.red = 161;
color.rgb.green = 161;
color.rgb.blue= 161;
myDoc.selection.fill(color);
//variable stores alpha channel name
var alphaName = myDoc.channels[3+a];
// variable stores lenght of alpha channel name
var lz = alphaName.length;
// declare index variable to initialize position of 1st  character of alpha channel name
var x= 0 ;
// truncate alpha channel name by removing all characters preceding the "\" symbol
while (alphaName.subString(x) != "\"){          (ExtendScript gives an error for this line and highlights the backslash and surrounding quotation marks)
    alphaName = alphaName.subString((x+1),z);
    x+=1;
    z-=1;
return alphaName;
// remove the backslash from alpha channel name
alphaName = alphaName.subString((x+1),z);
//  apply truncated alpha channel name to corresponding layer
myDoc.artLayers[a].name = alphaName;

while (alphaName.subString(x) != "\"){ 
should be
while (alphaName.subString(x) != "\\"){ 

Similar Messages

  • NEF files from Nikon d800 not visible in bridge and photoshop cs6- using mac ver.10.8.5. downloaded plugin from site 8.3 but issue unresolved

    NEF files from Nikon d800 not visible in bridge and photoshop cs6- using mac ver.10.8.5. downloaded plugin from site 8.3 but issue unresolved

    You can install and use Camera Raw 8.8 with OSX 10.8  Go to Help > Updates in Photoshop CS6

  • Is it possible to add button in the main tool panel of AI cs6 using javascript?

    Hello freinds,
    Is it possible to add  button in the main tool panel of AI cs6 using javascript?
    or is there any other way of adding the ui component to the tool panel..
    is it feasible??

    you can't add buttons to the tool panel using javascript, your only option is to create a plugin, you'll need C++ for that.
    yes, you'll need the SDK...if you need help with that, there's a dedicated forum for it
    http://forums.adobe.com/community/illustrator/illustrator_sdk?view=discussions

  • Trying to figure out how to use a video's alpha channel to define its hitspace for a button

    Hello, I'm trying to figure out how to use a video's alpha channel to define its hitspace for a button. I would greatly appreciate anyone's help with this.

    Currently I'm doing an image sequence inside of a movie, and putting the movie in the button. I hope that's what you're asking. Not sure if I entirely understand your question. (Been a little while since I used the interactive side of Flash)
    Anyway if you have a specific process that you personally do that works I'd happily conform to your solution.

  • How to set alpha channel names in a format plugin?

    I am writing a format plugin with 6 color planes for CMYK mode. I want to set the apha channel names for planes 5 and 6 to "White" and "Clear" instead of "Alpha 1" and "Alpha 2" when I read the color data from my file. How do I set the alpha channel names?
    Thanks!

    I am still trying to find a solution to this.  The propChannelName is read only and the documentInfo structure is NULL when reading.  Any suggestions?

  • Automator or Applescript using png files with alpha channel

    I have hundred of png files with alpha channel.
    I want to suppress alpha channel.
    How can i do it using Automator or Applescript ?
    Thank you very much.

    You can use the free command line image processing tool ImageMagick in your Applescripts or Automator workflows, as well as from a Terminal shell.
    You can download ImageMagick from http://www.imagemagick.org, but Cactuslab has simplified installation by putting together an installer package. It’s available at  http://cactuslab.com/imagemagick/. Download the package and double-click on it. Follow the instructions to install. It will install ImageMagick into /opt/ImageMagick and add it to your $PATH by creating a file in /etc/paths.d/. Restart your computer for the changes to take effect.
    The two ImageMagick commands we’re concerned with are “convert” and “mogrify”. Convert is more efficient for multiple and piped operations on the same image file, and mogrify is more efficient for batch processing. Generally speaking, convert will output a file separate from the input file. Unless a path is specified, mogrify will overwrite the input file with the output file. An important distinction.
    You can perform various operations on the alpha channel using arguments after either the convert or mogrify command. Two of the available arguments are:
    -alpha off - Disables the image's transparency channel. Does not delete or change the existing data, just turns off the use of that data.
    -alpha remove - Composite the image over the background color.
    Also of use are the -flatten and -background options:
    -flatten - overlay all the image layers into a final image and may be used to underlay an opaque color to remove transparency from an image.
    -background - sets the background color.
    Start off using the convert command with a single image to see the effect and adjust to your liking. Once you’ve achieved the desired outcome, then use the mogrify command to batch process the chosen images.
    Before getting into how to use Automator or Applescript in your workflow, use Terminal and the command line to see the effect on a single image. Copy one image to your ~/Desktop. In Terminal change the directory to ~/Desktop by typing the following command and pressing the Enter key:
    cd ~/Desktop
    Then choose the option you are looking for, -alpha remove for instance, type the following command and press the Enter key:
    convert input-photo.png -alpha remove output-photo.png
    You can check the alpha channel (transparency) and background in the Preview app, go View > Show Image Background from the menu bar.
    Once you’re ready to batch proces, place all the photos you want to convert with the same command into one folder. Copy the folder to your ~/Desktop. Let’s assume you’ve labeled the folder “InPhotos”. It’s prudent to manipulate copies in case something goes amiss. In that event you can copy the folder with the originals again and start over. Create a new empty folder on your ~/Desktop and call it “OutPhotos”. Let’s also assume your home directory is called “Me”. The following command will process the photos from the InPhotos folder and put them in the OutPhotos folder:
    mogrify -alpha remove -path /Users/me/Desktop/OutPhotos/ /Users/me/Desktop/InPhotos/*png
    According to Apple Technical Note TN2065:
    "when you use just a command name instead of a complete path, the shell uses a list of directories (known as your PATH) to try and find the complete path to the command. For security and portability reasons, do shell script ignores the configuration files that an interactive shell would read"
    So, you need to use the full path to to ImageMagick commands, unlike in the shell where you can just use the command name.
    To batch process using Automator, use the “Run Shell Script” action (note: retain the single space at the beginning of the last line):
    /opt/ImageMagick/bin/mogrify \
    -alpha remove \
    -path /Users/Me/Desktop/OutPhotos/ \
    /Users/Me/Desktop/InPhotos/*png
    To batch process using Script Editor (Applescript), use the “do shell script” command:
    do shell script "/opt/ImageMagick/bin/mogrify -alpha remove -path /Users/pd/Desktop/OutPhotos/ /Users/pd/Desktop/InPhotos/*png"
    Further info on ImageMagick:
    http://www.imagemagick.org/script/command-line-options.php#alpha
    http://www.imagemagick.org/Usage/masking/#remove
    http://www.imagemagick.org/index.php
    http://www.imagemagick.org/script/command-line-tools.php
    http://www.imagemagick.org/script/command-line-options.php
    Examples:
    The original PNG image:
    -alpha off:
    -alpha remove:
    -background black -flatten:
    -background blue -flatten:
    -channel alpha -evaluate Divide 2:
    -channel alpha -evaluate Divide 2 -background black -flatten:

  • Drawing Lines Photoshop CS4 using JavaScript

    I am new to javascript and have read a manuel on the basics of javascript in regards to photoshop. I was just wondering how to draw a straight line using javascript. Thanks.

    You could start by looking at the sample scripts that ship with photoshop to see a coding sample of stroking a selection. Then look at the doc on making selection and paths etc.
    // Copyright 2002-2007.  Adobe Systems, Incorporated.  All rights reserved.
    // Create a stroke around the current selection.
    // Set the stroke color and width of the new stroke.
    // enable double clicking from the Macintosh Finder or the Windows Explorer
    #target photoshop
    // in case we double clicked the file
    app.bringToFront();
    // debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
    // $.level = 0;
    // debugger; // launch debugger on next line
    if (app.documents.length > 0)
        if (app.activeDocument.activeLayer.isBackgroundLayer == false)
            var strtRulerUnits = app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.PIXELS;
            var selRef = app.activeDocument.selection;
            var offset = 10;
            var selBounds = Array(Array(offset, offset), Array(app.activeDocument.width - offset, offset), Array(app.activeDocument.width - offset, app.activeDocument.height - offset), Array(offset, app.activeDocument.height - 10));
            selRef.select(selBounds);
            selRef.selectBorder(5);
            var strokeColor = new SolidColor();
            strokeColor.cmyk.cyan = 20;
            strokeColor.cmyk.magenta = 90;
            strokeColor.cmyk.yellow = 50;
            strokeColor.cmyk.black = 50;
            app.displayDialogs = DialogModes.NO;
            selRef.stroke(strokeColor, 2, StrokeLocation.OUTSIDE, ColorBlendMode.VIVIDLIGHT, 75, true);
            app.preferences.rulerUnits = strtRulerUnits;
            selRef = null;
            strokeColor = null;
            selBounds = null;
        else
            alert("Operation cannot be performed on background layer");
    else
        alert("Create a document with an active selection before running this script!");

  • Photoshop CS6 used on an extended desktop

    Very strange reactions from Photoshop CS6 when used on my Lenovo ThinkPad in an extended desktop situation. Any attempt to open an image in Photoshop is unsuccessful in showing the actual image, despite the layers box shoing the thumbnail, the "open ifle" text box at the top indicating it is open, and the image details box also indicating correct data for the image file.  If I close down extended desktop Photoshop works just fine. If I extend the desktop once Photoshop is running, I can move the open window to the extended desktop and it also works fine. Once I close Photoshop I am back to square one. Any insights appreciated.

    RbertieA wrote:
    Any attempt to open an image in Photoshop is unsuccessful in showing the actual image, despite the layers box shoing the thumbnail, the "open ifle" text box at the top indicating it is open, and the image details box also indicating correct data for the image file.
    That's a pretty solid sign of a display driver problem.
    Is your laptop using an Intel GPU?  Intel drivers have traditionally been kind of iffy with regard to accelerating Photoshop.
    You may be able to find an updated display driver for your setup that gives you better results.  Exhaust this possibility first.
    Or you might find that Photoshop is made usable by turning off the [  ] Use Graphics Processor setting in Edit - Preferences - Performance.  You lose some features with this approach, however.
    -Noel

  • Can Photoshop Cs6 Use all 12 Cores ?

    Hi,
       I'm purchasing a new Mac Pro 12 Core Desktop and I was wondering can Cs6 use all 12 cores of the processor  ? Also, How much real ram can photoshop use ?
    Thanks

    You can read about it in this page: http://helpx.adobe.com/photoshop/kb/optimize-performance-photoshop-cs4-cs5.html
    The more cores you use, the less you get from each additional core. Therefore, Photoshop doesn’t run four times as fast on a computer with 16 processor cores as on a computer with four cores. For
    As far as Memory goes, 64-bit version of Photoshop CS6 can use as much RAM as you have installed on your computer.
    Photoshop version
    OS version
    Maximum amount of RAM that Photoshop can use
    CS4, CS5, CS6 32 bit
    Windows 32 bit
    1.7 GB
    CS4, CS5, CS6 32 bit
    Windows 64 bit
    3.2 GB
    CS4, CS5, CS6 64 bit*
    Windows 64 bit
    As much RAM as you can fit in your computer
    CS4, 32 bit
    Mac OS
    3 GB
    CS5, 32 bit
    Mac OS
    2.1 GB
    CS5, CS6 64 bit
    Mac OS
    As much RAM as you can fit in your computer
    What will really make a difference apart from RAM and processor is your Hard Drive itself. Faster drive equals lower processing latency, resulting in faster saves and so on. Your scratch disk highly depends on the hard drive that you use.

  • Photoshop CC is not showing save "Alpha Channels" to be checked!

    This hasn't happened before!   As in... it didn't happen as recently as yesterday.
    I have a 3 layer image, 2 of them with a large transparent area.  I will be importing this into After Effects.
    It allows me to check "layers" but not to preserve the transparency.  "Alpha Channels" is greyed out.
    When I import into AE, even in the media browser the transparency is gone.  The transparent area is now black.  Ditto when I drag it into the composition canvas.
    Mode = RGB, 18 bit
    When I import the files from yesterday that *did* preserve the transparency, they still keep the transparency.  So I know it's not a problem in AE.
    This is where it gets super weird.  When I take yesterday's file, open it, and try to save it under a new name -- TODAY IT DOESN'T ALLOW ME TO CHECK "ALPHA CHANNELS".
    What have I done to take this option away?

    HOLY CRAP -
    Indeed, I did not have that.
    So I added a channel, and it automatically showed up as Alpha 1...... and my whole image turned red.
    When I turned off the image channel, it went back to normal.
    Am I possessed?  

  • Photoshop CS6 using an Asus 4K monitor

    I have the above monitor and running Photoshop CS6, the tool menus are so small I'm barely able to see them.  Is there a fix for this?

    UI Scaling for Windows was introduced in Photoshop CC 2014 (just as soon as we could work with Microsoft to fix the OS UI scaling code).

  • Upgrading Photoshop CS6 using the cloud.

    Every time I try to upgrade Photoshop CS6 with the cloud I get error U44MIP7. Then after a few weeks it upgrades ok. Any ideas? I don't think Adobe is really ready to prime time on the cloud yet.

    It appears the 13.0.1.2 update is the problem.
    Here is a summary of the fix:
    1) UNinstall Photoshop (no need to uninstall anything else in CS6)
    2) Reboot your computer (just to make sure nothing is hanging around in memory)
    3) Install Photoshop and immediately quit the Creative Cloud app
    4) Run photoshop
    5) Go to HELP > UPDATES
    6) EXPAND the update group and UNselect the 13.0.1.2 update
    7) Apply the 13.1.2 update

  • Downloading Photoshop CS6 using Application Manager

    I have just purchased CS6 Cloud and successfully downloaded the Application Manager. I am now attempting to download just Photoshop CS6 but it has stopped at 48%. This is the second attempt where it has stopped at exactly the same point. I have iMAC 10.7 and mobile broad band which peaked at 3-4Mb/sec. What size is the download file? I left it overnight but now the comms are zero. I would rather get advise before re-starting.

    The file size of Photoshop CS6 is approximately 960 MB.
    Did you refer to http://helpx.adobe.com/creative-suite/kb/troubleshoot-update-issues-cs5-cs5.html and http://helpx.adobe.com/creative-suite/kb/troubleshoot-creative-cloud-installation-download .html and try troubleshooting the application manager?
    Thanks
    Nikhil

  • Can't open Raw files in Photoshop CS6 using Nikon D7100?

    I have a Nikon D7100 and recently did a photoshoot where I shot in Raw. Upon uploading my images and then attempting to open them in Photoshop it came up with a pop up saying that photoshop is unable to open that camera raw file. I have downloaded the adobe recommended converters but those don't seem to work either. Help?

    The Nikon D7100 didn't get support until Camera Raw version 7.4; CS6 shipped with 7.0 (and is compatible up until 8.3). Did you go through Help > Updates?
    Also, versions of Camera Raw above version 8.3 won't work on anything below Windows 7 or Mac 10.7. You'll have to "upgrade" to at most 8.3 to continue using it on the other operating systems.

  • Photoshop CS6 using Start up disk

    Hi I am editing some large PSB's in CS6 but even though my scratch disks are assigned to seperate drives photoshop still seems to be using my startup disk and filling it up very quickly. It is fine in CS5 which is leading me to think that maybe the autosave is saving to my startup disk. Is there anyway to change the location of the autosave? I did a quick search and couldn't find any info on the location of autosaves on Mac os x 10.7.

    Chris:
    In PS CS6's Prefs., I have set my Scratch to be on a separate partition on a second HD (called "Scratch") and my Auto-Saved PS files seem to be beeing saved to that location too:
    Is this only possible on a Mac running OSX 10.6.8 (Snow Leopard)?

Maybe you are looking for

  • Code for Hot spot in ALV report to call transaction

    Hi, I  hv never use hot spot to link as a call transaction can u give the link or code how to make hot spot on a particular fields  i am working on a ALV report in that report in the belnr coloumn when user click on belnr i want to call FB03 transact

  • Publishing: white screen instead of slides

    hi. i'm using captivate for recording and publishing presentations (lasting one hour each, incl. audio and slides). this time i was using the "application"-version as i was only having .pdf for the presentation. previewing the project, the recorded s

  • Problem in adding Custom Provider for Work Management Service

    Hello, I'm facing an issue in adding custom provider for work management service. As you are aware, Work management service is a Provider model and we can integrate with other systems by adding custom providers. So with that confidence, i have starte

  • Dacl on ACS 5.1 and Catalyst switch 3560

    Dear all I have ACS 5.1 and Catalyst switch 3560 with version 12.2(53)SE. I configure a dacl on the ACS and I use it on authorization profile. This authrization profile is used on access policy. I tried the authentication but it doesn't work. I check

  • Best way to keep track of family members, etc

    Hi- I am a hobby photographer, and have been playing around with the trial version Aperture to replace iPhoto, and I have some questions. 1. What is the best way to keep track of family members? For example, I like to basically keep track by setting