Help editing the imageTracing.jsx Script

Hello, I am looking for guidance on how to properly edit the imageTracing.jsx script in Illustrator CC. At the moment it only defaults to using a basic black and white trace, I need the trace to use one of my presets, expand the trace and save it. I need to run thousands of frames of bitmap animation through a batch trace process essentially. I've tried to batch it through Bridge, but it just throws up and error (59 I believe) and I've set up an action to try and batch that way but it never completes the batch by expanding the trace.
I've tried editing the script myself, but if I change the preset numeral it appears to break the save and close functionality of the script. Not quite sure what I am doing wrong. I've also tried adding a line for expanding the trace but I may be using the wrong syntax  --- tracing.expandTracing(); ---
Below is the default script as shipped with Illustrator, no changes made.
// Main Code [Execution of script begins here]
// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
// Collectable files
var COLLECTABLE_EXTENSIONS = ["bmp", "gif", "giff", "jpeg", "jpg", "pct", "pic", "psd", "png", "tif", "tiff"];
var destFolder, sourceFolder;
// Select the source folder
sourceFolder = Folder.selectDialog( 'Select the SOURCE folder...', '~' );
//sourceFolder = new Folder("C:/Users/<Username>/Desktop/1");
if(sourceFolder != null)
    // Select the destination folder
    destFolder = Folder.selectDialog( 'Select the DESTINATION folder...', '~' );       
    //destFolder = new Folder("C:/Users/<Username>/Desktop/2");
if(sourceFolder != null && destFolder != null)
        //getting the list of the files from the input folder
        var fileList = sourceFolder.getFiles();
        var errorList;
        var tracingPresets = app.tracingPresetsList;
        for (var i=0; i<fileList.length; ++i)
            if (fileList[i] instanceof File)
                 try
                        var fileExt = String(fileList[i]).split (".").pop();
                        if(isTraceable(fileExt) != true)
                            continue;
                        // Trace the files by placing them in the document.
                        // Add a document in the app
                        var doc = app.documents.add();
                        // Add a placed item
                        var p = doc.placedItems.add();
                        p.file = new File(fileList[i]);
                        // Trace the placed item
                        var t = p.trace();
                        t.tracing.tracingOptions.loadFromPreset(tracingPresets[3]);
                        app.redraw();
                        var destFileName = fileList[i].name.substring(0, fileList[i].name.length - fileExt.length-1) + "_" +fileExt;
                        var outfile = new File(destFolder+"/"+destFileName);
                        doc.saveAs(outfile);
                        doc.close();
                catch (err)
                        errorStr = ("Error while tracing "+ fileList[i].name  +".\n" + (err.number & 0xFFFF) + ", " + err.description);
                        // alert(errorStr);
                        errorList += fileList[i].name + " ";
       fileList = null;
       alert("Batch process complete.");
else
       alert("Batch process aborted.");
sourceFolder = null;
destFolder = null;
function isTraceable(ext)
     var result = false;
     for (var i=0; i<COLLECTABLE_EXTENSIONS.length; ++i)
          if(ext == COLLECTABLE_EXTENSIONS[i])
            result = true;
            break;
    return result;
And this is the amended version with my change to lines 57 and 58.
// Main Code [Execution of script begins here]
// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
// Collectable files
var COLLECTABLE_EXTENSIONS = ["bmp", "gif", "giff", "jpeg", "jpg", "pct", "pic", "psd", "png", "tif", "tiff"];
var destFolder, sourceFolder;
// Select the source folder
sourceFolder = Folder.selectDialog( 'Select the SOURCE folder...', '~' );
//sourceFolder = new Folder("C:/Users/<Username>/Desktop/1");
if(sourceFolder != null)
    // Select the destination folder
    destFolder = Folder.selectDialog( 'Select the DESTINATION folder...', '~' );       
    //destFolder = new Folder("C:/Users/<Username>/Desktop/2");
if(sourceFolder != null && destFolder != null)
        //getting the list of the files from the input folder
        var fileList = sourceFolder.getFiles();
        var errorList;
        var tracingPresets = app.tracingPresetsList;
        for (var i=0; i<fileList.length; ++i)
            if (fileList[i] instanceof File)
                 try
                        var fileExt = String(fileList[i]).split (".").pop();
                        if(isTraceable(fileExt) != true)
                            continue;
                        // Trace the files by placing them in the document.
                        // Add a document in the app
                        var doc = app.documents.add();
                        // Add a placed item
                        var p = doc.placedItems.add();
                        p.file = new File(fileList[i]);
                        // Trace the placed item
                        var t = p.trace();
                        t.tracing.tracingOptions.loadFromPreset(tracingPresets[1]);
  tracing.expandTracing();
  app.redraw();
                        var destFileName = fileList[i].name.substring(0, fileList[i].name.length - fileExt.length-1) + "_" +fileExt;
                        var outfile = new File(destFolder+"/"+destFileName);
                        doc.saveAs(outfile);
                        doc.close();
                catch (err)
                        errorStr = ("Error while tracing "+ fileList[i].name  +".\n" + (err.number & 0xFFFF) + ", " + err.description);
                        // alert(errorStr);
                        errorList += fileList[i].name + " ";
       fileList = null;
       alert("Batch process complete.");
else
       alert("Batch process aborted.");
sourceFolder = null;
destFolder = null;
function isTraceable(ext)
     var result = false;
     for (var i=0; i<COLLECTABLE_EXTENSIONS.length; ++i)
          if(ext == COLLECTABLE_EXTENSIONS[i])
            result = true;
            break;
    return result;
Thanks in advance for your help, as you can imagine, manually tracing thousands of images for a client job will be a nightmare if I can't sort out a batch.

hello,
after line 32 :
var tracingPresets = app.tracingPresetsList;
do an alert :
alert( app.tracingPresetsList );
it'll show you the name of the differents presets
then line 57, call the good preset :
t.tracing.tracingOptions.loadFromPreset('here the name of your preset');
for expanding :
change line 58 like that :
t.tracing.expandTracing();
you forget (t.) at the beginning
best wishes for the new year

Similar Messages

  • Imagecatalogue.jsx script

    Hi.
    I'm using the imagecatalogue.jsx script to populate a page.
    At the moment, the page it populates is a custom size.
    does anybody know how i make populate to an A4? Is there a code i can put into the script?
    Any help is very much appreciated.
    Many thanks

    Just figured it out - it populated to what ever the pre defined workspace was...doh?

  • Users priveleges who is able to edit the RMAN script in OEM

    Hi
    Can anyone help me, how to find the list of users who has privileges to change/edit the RMAN script in OEM?
    Thanks

    Hi,
    I believe its required DBA privileges as well as OS level login credential to edit the job,
    you can Query from dba_role_privs which user having DBA role assign, and find those user having OS level Credential.
    HTH

  • Help alternating find and changebylist.jsx script that comes with CC samples

    i did alternate the same vbs script to suit my needs and i was happy about it (likeChild when you give him his favourite toy) but i run in som problems with it....when i copy and place the vbs script on other computer i want it to use it invokes CS6 instead of CC...i tried everything i could think of but no luck...same thing happens every time i try to use it open CS6 instead CC in which i run it...on the computer i did write it the script run like charm(on both computers i have CS6 and CC)....so i decided to use the jsx version of same script....
    then when i try that script:
    1. the dialog box is opening only when my cursor is in textframe allowing me to select what i want to change 1.document 2.selected story. 3 selection
    2. when i select 2 text frames and on document i have 3 or more the script does not change in 2 selected frames instead it does in all frames
    i need to alternate this script
    when i select text frame to open dialogbox allowing me to pick 2 of 3 above mentioned options the number 2 and 3
    so it do the find and change only in text frames i selected (when it is selected with selection tool) not in all frames
    i tried to do that my self but im kinda short of knowledge
    i tried to alternate the case dialog box is open adding the line case "TextFrame": in this portion of script
    if(app.documents.length > 0){
            if(app.selection.length > 0){
                switch(app.selection[0].constructor.name){
                    case "InsertionPoint":
                    case "Character":
                    case "Word":
                    case "TextStyleRange":
                    case "Line":
                    case "Paragraph":
                    case "TextColumn":
                    case "Text":
                    case "Cell":
                    case "Column":
                    case "Row":
                    case "Table":
                        myDisplayDialog();
    and it work for invoking the dialog box when the text frame is selected but then it only do changes in first textframe selected not in all selected....
    so i tried to experiment with this line
    if(myResult == true){
            switch(myRangeButtons.selectedButton){
                case 0:
                    myObject = app.documents.item(0);
                    break;
                case 1:
                    myObject = app.selection[0].parentStory;
                    break;
                case 2:
                    myObject = app.selection[0];
                    break;
            myDialog.destroy();
            myFindChangeByList(myObject);
        else{
            myDialog.destroy();
    by changing the number to 1 or 2 or 3 but that only told the script that if i have 2 text frame selected to do search in second text frame (incase of number 1) or if i have 3 selected and in case of numer 2 only do script in 3 text frame
    i need help please

    hello,
    after line 32 :
    var tracingPresets = app.tracingPresetsList;
    do an alert :
    alert( app.tracingPresetsList );
    it'll show you the name of the differents presets
    then line 57, call the good preset :
    t.tracing.tracingOptions.loadFromPreset('here the name of your preset');
    for expanding :
    change line 58 like that :
    t.tracing.expandTracing();
    you forget (t.) at the beginning
    best wishes for the new year

  • Edit the scripts of speech recognition

    I would like to know if I can edit the scripts to be able to command the mac with custom voice commands (in the text and the language), and how I have to do for doing that. thanks

    See if this helps:
    http://forums.macrumors.com/showthread.php?t=299688

  • Some of my photos in iphoto turn blank (white) when I tried to edit the size like zoon in and out.Can someone help me on this?

    Some of my photos in Iphoto turn blank (white) when I tried to edit the size like zoon in and out.Can someone help me on this?

    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • I hope someone gets this who can help me. i don't find anything helpful in the help section of icloud. i'm using my 4th generation itouch for about 3 weeks with the ical. but today when i tried to edit an event or d an event a window would pop up and sa

    i hope someone gets this who can help me. i don't find anything helpful in the help section of icloud. i'm using my 4th generation itouch for about 3 weeks with the ical. but today when i tried to edit an event or add an event a window would pop up and say "event can't be saved" or "no calendar chosen" or something like "this event doesn't belong with this calendar" and stuff like that.
    can you please help me fix this?

    You could repartition your drive to have a different OS X with the older iTunes there, and the newer iTunes on the existing partition. Back up everything beforehand. See Kappy's advice in this thread. Partitioning my Hard Drive

  • I recorded a panel presentation on my Ipod and would like to edit the recording on my itunes so I can export the recording and send it to my colleagues over the internet.  I was able to import the recording to my itunes library but need help editing it.

    Hello, thanks in advance for your help.  I recorded a panel presentation on an ipod and would like to edit the audio recording to just one portion of the recording.  I was able to import the audio into my itunes 11.1.3 music library but I have not been able to edit the length of the recording.  I followed an online tutorial and was able to edit when the recording starts and stops on the recording but I haven't been able to edit out the parts of the recording that I dont want.  Also when I try to export it to my Desktop or to Garageband (not sure if that helps or not) I am not able to export it.  It is currently a .WAV file.  I would like to edit the length of the recording and then export the file onto my desktop.  I would like to email the presentations to my colleagues online so I could also use advice on how to make it a smaller file since it is current 945.6 MB.

    iTunes isn't an editor. You need an app that's intended for editing audio files, like Adobe Audition (http://www.adobe.com/products/audition.html) or Audacity (free in the App Store).

  • Can anyone help me create a relink script to simply open up the relink dialogue box?

    Can anyone help me create a relink script to simply open up the relink dialogue box?

    the "Relink" command uses the same dialog as the "Place" command, with the exception of having the "Replace" option checked...so, use Ctrl+Shift+P to bring up the Place dialog, select your new image then check the "Replace" check box.
    if checking "Replace" with the mouse slows you down, after selecting your image, press "tab" key 3 times to switch focus to it, then press space bar to check it, then ok to place.

  • I have never used my mac for desktop publishing before and am having some problems.  This sounds really dumb, but I can't figure out how to put a border around a text box.  Also, how do you edit the border, i.e. border color, thickness, etc. Help!

    I have never used my mac for desktop publishing before and am running into some real problems.  How do you put a border around a text box?  Can you edit the border - color, thickness, etc.?  Help!

    I think the best solution is to read Pages documentation, go to Help and you have a long list of options. Pages is capable of quite sophisticated things, some features are above Nisus or Mellel, so it is not so simple to summarize things in a few lines.

  • In iTunes I click on a song and when I click on the "get info" tab, it opens up but everything is gray - locked, therefore, I cannot edit the year or genre of the songs. Not every song is locked, only certain ones for some reason. Any help?

    In iTunes I click on a song and when I click on the "get info" tab, it opens up but everything is gray - locked, therefore, I cannot edit the year or genre of the songs. Not every song is locked, only certain ones for some reason. Any help?

    I ran into the same problem, I think that, If you tab on a song that is on your IPOD, and the song data is grayed-out, I think it means that the song is probably twice on your IPOD and that the iTunes directory can not edit THAT song data for two (or more) files @once. Check if this is the case, sinceI have the same problem,am looking for a way to have One and the same song in more playlists but only keep the song once on the IPOD.

  • Using VB API in VBA to edit the Calc Scripts

    Guys,
    Does anyone of you have VBA source code/examples utilizing Essbase API for the following operation.
    I want to copy Calc Script from Server to the client, edit the Script using VBA and copy back the Script to the Server. Any kind of info is appreciated.
    Thanks in advance
    HYPuser

    I posted some real sample code a while back for a completely different function (member renames).
    Renaming Existing Member Names
    So while you'll have to write the calc modification code yourself (or ask Glenn his rate ;-)), this at least shows you how the initialization / login / termination of the API would work. That's probably the most confusing aspect of using the VB API for the first time anyway.
    All that said, if this is from Excel and the user will already be logged in via the Excel Add-In, I believe that you can make life much easier and grab the hCtx directly without any initialization / login/ termination worries. I probably should have done that myself in the example I gave. See Tim Tow's posts in this thread:
    API
    EDIT: Two things I just noticed - first, the code sample I gave even has an example of polling for ProcState, so that gets you closer than I thought! Second, remembered that the line that reads...
    While ProcState.State ESB_STATE_DONE
    ...should actually have a 'less than / greater than' symbol between ProcState.State and ESB_STATE_DONE. Can't get the forum to display them correctly, even in code tags...
    Edited by: TimG on May 16, 2011 2:55 PM

  • I have just created a new playlist, at the same time I have updated the ITunes software and that of my ITouch. My problem is that today I have been trying to edit the playlist and the edit playlist is greyed out please help

    I have just created a new playlist, at the same time I have updated the ITunes software and that of my ITouch. My problem is that today I have been trying to edit the playlist and the edit playlist is greyed out please help.
    I have been in preferences and checked manually edit etc and still no joy. I must be missing something.
    Susan

    From Here   http://support.apple.com/kb/HE37
    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.

  • How to edit the installation scripts in the supporting objects

    I wanted to update one of the installation scripts in the supporting objects. I clicked into that script and use the "script editor" tab. After editing the script, I clicked "Apply Changes" button. It redirected me to the upper level of the page. When I reopen the script, the content of this script is messed up and has the content of another script, not what I have changed. What could happen with it? There is one case that the script was all wiped out!
    One general question, how can I easily update the install scripts and reload it without export and import the whole application? or Can I?
    Thanks
    Fengting

    Fengting,
    I am not sure what causes this, but I have had the same issue with shared components >> report queries. Sometimes if you have multiple report queries it becomes impossible to edit any of them. If I remember correctly I tried using a different browser and everything seemed to work ok. I was using Firefox when I was having the issue.
    Sorry this is not an answer, but I feel your pain!
    Cheers,
    Tyson Jouglet

  • I have lost the File Edit View History Bookmarys Yahoo Tools Help and the Home Icon how do I get them back I cant find anywhere to click to get them back can anyone help please.

    I have lost the bar that has my file Edit View History Bookmarks Yahoo tools and help also the Home Icon with back and refresh Icon I cant find anywhere to click to get them back can anyone please help me.
    Thanks ([email protected])

    Make sure that you do not run Firefox in full screen mode (press F11 or Fn + F11 to toggle; Mac: command+Shift+F).<br />
    If you are in full screen mode then hover the mouse to the top to make the Navigation Toolbar and Tab bar appear.<br />
    You can click the Maximize button at the top right to leave full screen mode or right click empty space on a toolbar and use "Exit Full Screen Mode" or press F11.<br />

Maybe you are looking for

  • Please help...Can't find dependent libraries.

    I've searched and read, and tried several things but every time I run my application I get this: java.lang.UnsatisfiedLinkError: C:\JBuilderX\Projects\AlwaysOnTop\AlwaysOnTop.dll: Can't find dependent libraries      at java.lang.ClassLoader$NativeLib

  • SQL Loader and numeric types

    I'm using SQL Loader to import data from a file, but I'm having trouble with numeric types. I'm trying to import an amount into a table. The amount field in the table is of type NUMBER(11,2). I suppose that Double is the correct type to use in the ct

  • Search function (Spotlight) not working in Mail

    Hi, This just started happening today on my PowerBook G4. The search function in Mail is not working. No matter which mailbox I go into to search for a term it shows 0 results when I know for a fact there should be multiple results. If I search for a

  • Java.sql.Timestamp( long time ) bug?

    It appears to wipe milliseconds clean. If I pass in the current time such as: Timestamp t = new Timestamp( 1012427790890 ); and then do a t.getTime(); it returns the correct time but with no millis: 1012427790000

  • Batch White Balance using a reference pixel?

    Hi, I have shot a time lapse image sequence that includes change from day to night & vice versa. The automatic white balance produces unsatisfying results. Since it's always the same scene, what I would like to do is this: Select one pixel in one of