Encoding and app.doScript

Hi all,
I try to use the function app.doScript to run an applescript. This script use the terminal to look if an picture has an alpha channel.
My function works with files who not contains special char.
Has some one an idea to correct this bug?
I become the following error:
set result to do shell script "sips -g hasAlpha '/Users/bastieneichenberger/Desktop/indd_resize_script/2013-10-19_17-56-00__test.indd/Lin ks/Capture d’écran 2013-10-05 à 12.05.19.png'"
Warning: /Users/bastieneichenberger/Desktop/indd_resize_script/2013-10-19_17-56-00__test.indd/Link s/Capture d’e<0301>cran 2013-10-05 a<0300> 12.05.19.png not a valid file - skipping
Error 4: no file was specified
Try 'sips --help' for help using this tool
#target indesign
var file_path = "/Users/bastieneichenberger/Desktop/indd_resize_script/2013-10-19_17-56-00__test.indd/Links/Capture d’écran 2013-10-05 à 12.05.19.png"
alert(has_item_alpha_channel (file_path) );
function has_item_alpha_channel (file_path){
    if(File.fs == "Windows"){
        throw new Error("the function has_alpha_channel works only on mac os x");
    var appleScript = "set result to do shell script \"sips -g hasAlpha '"+  file_path +"'\"";
    $.writeln(appleScript);
    var result = app.doScript(appleScript, ScriptLanguage.applescriptLanguage);
    var res = result.match("hasAlpha: yes");
    if(res != null){
        res = true;
    else{
        res = false;
    return res;

You should post in the scripting forum. It looks like you are making things too complicated. You shouldn't need a shell script to check for alpha channels—a list of alpha channels is stored in a placed image's clipping path property.
This AppleScript displays the count of alpha channels in a selected image (you should be able to do the same in JS):
--x returns a list of alpha channels—will return {} if there are none
tell application "Adobe InDesign CS6"
    set x to alpha channel path names of clipping path of selection of active document
    set c to count of x
    display dialog "There are " & c & " alpha channels in the selected image"
end tell

Similar Messages

  • AIS CC: how undoing the actions of a JS run via app.doScript

    Hello,
    AIS CC (9.0)
    I wrote a JavaScript, which I can properly run through app.doScript(UndoModes.fastEntireScript, etc.).
    Now, at a given time, I would like to programmatically undo the actions of my own script.
    The various resources I have got here (InDesign_ScriptingGuide_JS (CS6), InDesign_ScriptingTutorial, the ExtendScript Toolkit Object Model browser) suggest things (app.undo(), app.documents.item(0).undo(), etc.) which fail, when executed on my AIS CC.
    Any idea or tip, on how to undo actions submitted via doScript on AIS CC?
    Thanks in advance!
    Kind regards,
    GB
    Snippet:
    var main = function()
         // something
    app.doScript(
         main,
         ScriptLanguage.javascript,
         undefined,
         UndoModes.fastEntireScript
         ); // << this works perfectly: the actions in the "main" function are executed
    app.undo(); // << this will fail with "app.undo is not a function"

    Thanks for your fast reply.
    you're undoing the entire script, which is probably not what you want.
    Undoing everything embedded in my "main" function is really what I want to achieve.
    Whether it's a bunch of complex code, or nothing at all (as in my snippet, where "main" contains only a comment line ), it's what I want.
    the recommendation is to us entireScript
    I changed my "UndoModes.fastEntireScript" into "UndoModes.entireScript", as you suggested; with no avail so far: I still get the same "is not a function" error.
    Actually, I have the feeling that I do not understand/master the InDesign DOM here, and am simply trying to make a call to a method (undo) which does not exist in this class (app) - despite the Adobe Reference Manual says it does...
    It sounds an inefficient way to write a script
    My script makes some changes in an InDesign document ("main" function), then exports it to PDF (out of the "main" function).
    Then, the environment I work with (XMPie) will inject variable information in the InDesign document for the next recipient.
    At this time, I need the document to be reset to its original design.
    That's why I need to undo all the changes applied by the "main" function.

  • Encoder and LS184 Clock Converter Problems

    I am trying to implement position measurements using a 9000 CPR and 1000 CPR encoder and a clock converter chip LS184 but I have trouble obtaining a consistent count with my PCI-6035E DAQ-STC counter. The count does not seem to be correct (9000 counts in one revolution, which is times 4 in X4 mode or 36,000 counts; I am getting around 14,000 and this is not even the same every time), and the count does not return to zero when turning the encoder back to the original position. I had that problem with the direct encoder connection to the counter (A to source, and B to DIO6), and obtained the LS184 clock converter chip to fix the problem. However, it is even worse with the clock converter. I tried different values of the bias r
    esistor but the problem was still there. What am I doing wrong?

    Hi Ed,
    The DAQ-STC counter/timer chip on your PCI-6035E card is not your most accurate counter/timer chip to perform encoder measurements. You are better off using a PCI-6601 card which is much more accurate and has real encoder capabilities.
    PCI-6601 (w/ NI-TIO Counter/Timer Chip)
    http://sine.ni.com/apps/we/nioc.vp?cid=3589〈=US
    The reason the NI-TIO chip is better suited for encoder measurements than the DAQ-STC is because of the following (which might also explain some of the difficulties):
    1) DAQ-STC can't reset the count after an encoder revolution (NI-TIO can w/ Z-Index line)
    2) DAQ-STC only has one encoder measurement mode and that is the 2-pulse encoder measurement mode. The NI-TIO has the X1, X2, X4, 2-pulse
    This essentially me
    ans that your DAQ-STC will count up when channel A leads B and count down if channel B leads A. There is no reference point, no ability to reset and no filters on the lines to prevent glitches.
    What is probably happening in your case is that you are measuring 9,000 pulses in one revolution and you are also measuring glitches on the line which is why you are getting the extra 5,000 counts. The DAQ-STC shipping example programs will give you some insight into programming your E Series counter to make encoder measurements but your errors are more likely caused by the fact that it is just a simple 2-pulse encoder (up/down encoder).
    Hope that helps. Have a good day.
    Ron

  • Binary and app.activeScript issue

    Hi all,
    I am trying to get a script running. The syntax looks like :
    #targetengine "foo"
    var scpt="@JSXBIN@[email protected]@MyBbyBnAge...";
    app.doScript(scpt);
    I get an error and it seems to be related to the use of app.activeScript.parent in the binary script.
    //In the binary
    //Script folder
    var scriptFolder = Folder(app.activeScript.parent);
    Is it something known or me doing something bad ?
    Is there a workaround, would it be better to do drastically different ?
    TIA for any input
    Best,
    Loic

    Try something like this:
    #targetengine "foo"
    Folder.current = app.activeScript.parent;
    var scpt="@JSXBIN@[email protected]@MyBbyBnAge...";
    app.doScript(scpt);
    and in you script access Folder.current....
    Harbs

  • App.doScript("HelloWorld.scpt","APPLESCRIPT_LANGUAGE");

    Before the Extension Builder I was able to call AppleScript in the doScript() and run an AppleScript threw SwitchBoard. Has AppleScript been removed from the new SDK? It still shows up in the Docs for ScriptLanguage.

    This is a package inside of a Extension Builder project for InDesign. It's just a button with that runs the run() function in this package. The problem is I can't get the project to compile because I get this error on doScript().
    Implicit coercion of a value of type String to an unrelated type com.adobe.indesign:ScriptLanguage.
    The HelloWorld.scpt is inside the project as a local resource. Do I need to load this an constant object and then load the path as a string?
    package mkt
    import com.adobe.csawlib.indesign.InDesign;
    import com.adobe.indesign.*;
    public class MarketingAutomationInDesign
    public static function run():void
    var app:Application = InDesign.app;
    var document:Document = app.documents.add();
    var pages:Pages = document.pages;
    var firstPage:Page = pages.item(0);
    var layers:Layers = document.layers;
    var firstLayer:Layer = layers.item(0);
    var textFrames:TextFrames = firstPage.textFrames;
    var myTextFrame:TextFrame = textFrames.add(firstLayer);
    myTextFrame.label = "Dude Hope this works.";
    myTextFrame.geometricBounds = new Array("6p","6p","36p","36p");
    myTextFrame.contents = "Hello World from a Creative Suite Extension and again";
    var myItem:* = document.pageItems.itemByName("Dude Hope this works.");
    app.doScript("HelloWorld.scpt","applescriptLanguage");

  • How can you use the same Apple ID for music and apps but have a different iCloud

    Collectively in my family we have 1 iPhone 2 ipod(4th gen) and 3 iPad mini's and we like to buy music and apps through the same Apple ID so that we can all share it but we also have a problem about the iCloud.
    My son has one iPod and one iPad and he would like his contacts and messages to be shared between HIS two devices but he would also like all of the pictures taken in the family to be shared
    The same for my daughter and for me.
    Is there a way of selecting which devices share what????
    Thanks a lot
    Acwills

    You could and should set up different iCloud accounts in "Settings > iCloud", so that every user has its own email account, calendars, reminders, notes, storage for backups and app data (files etc.), by the way everyone could also use his own account for iMessage (Settings > Messages > Send & Receive) and FaceTime (Settings > FaceTime) so that you all could write and call each other.
    Next the Apple ID for music, apps and other media: You all could just set up the ssame Apple ID in "Settings > iTunes & App Stores" for all your media purchases like songs, movies, apps etc.

  • My friend wanted to create a new iCloud account that was different to  her iTunes and app one when she deleted her iCloud account that was the same as her iTunes it won't let her log into her iTunes one now

    My friend wanted to create a new iCloud account that was different to  her iTunes and app one when she deleted her iCloud account that was the same as her iTunes it won't let her log into her iTunes one now what can I do to fix it she has paid or apps and songs and of she makes another account everything will be lost.
    Need help please :) thanks

    Ah thanks Razmee however there is NO option to delete the iCloud account in settings!

  • My safari menu bar is missing --the menu bar for desktop, HD, and apps appears, but when I click on Safari, it disappears, so I can no longer see my buttons for History, etc.  I think my husband (pc user) clicked it away.  Any ideas how to retrieve it?

    My safari menu bar is missing.  The menu bar for desktop, HD, and apps appears, but when I click on Safari, it disappears, so I can no longer see my buttons for History, etc.  I think my husband (pc user) clicked it away when borrowing my computer.  Any ideas how to retrieve it?  Thanks. 

    I too was having the same problem However, I could access both the menu bar and the dock by hovering my mouse over them so it wasn't a huge problem but I prefered having it there anyway. I was not in full screen mode and I could still go into full screen mode if I wanted to.  I found the easiest solution was to just quit safai and restart it, but it might not work for you considering you couldn't access you menu bar either way.
    I found this article that allows you to hide/show the menu bar and the dock through TextEdit (didn't work for me) http://www.mactricksandtips.com/2009/07/hide-the-menubar-or-dock-in-specific-app s.html It is pretty old so it might not work for lion and a bit risky if you don't know what you're doing so I wouldn't really recommend doing it this way.
    And KSheppard, I know it's not really any of my buisness, but the way to get answers to a question isn't by insulting others and being quick-tempered. Even if you feel like you were insulted first, don't try snapping at people who aren't obligated to help you. Honestly, it just makes everything easier if everybody is cooperative and polite.

  • My husband and I have separate iTunes accounts and multiple devices (iPads, iPhones, iPods etc) how do we share our music and apps between our devices if we have different iTunes accounts.

    Help! My husband and I have multiple devices (iPad, iPhone, iPod ) that we we have linked to individual iTunes accounts ie he has his account with iPad, iPhone, PC and iPod linked/sync and I have my account with iPhone, iPad, iPad mini, PC etc.. How do we share our music and apps across/between our accounts?

    It probably means that only one of you can use iCloud or at least sync calender/contacts with it. I would guess that you could manually manage the other phone as you have before.

  • How do I retrieve lost music and apps?

    While updating my iPod touch I lost all of my pictures, videos, music, and apps. How do I restore all of this lost memory?

    If you still have a backup, you can restore your device from that backup.
    Apps and other media can be downloaded again for free, they are not part of the backup made by iTunes:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    More info about the content of a backup and how to restore: iTunes: About iOS backups

  • TS3988 I changed my Apple ID to my new email address successfully for the iTunes and App store but it won't work for iCloud and it won't recognize my password. I read that this can't be done. How am I supposed to get into iCloud?

    I changed my Apple ID to my new email address successfully for the iTunes and App store but it won't work for iCloud and it won't recognize my password. I read that this can't be done. How am I supposed to get into iCloud? I plan on getting rid of my old email address which is my old Apple ID so how is that going to work?

    Same question Wish someone had replied!
    I changed my Apple ID to my new email and now cannot find any way to access icloud. Unfortunately I had allowed icloud to hijack my airbook files, so of course I am afraid I will lose them tomorrow when I exchange my iphone for a new one and cannot keep an icloud account i cannot access. What a poor sync system! Really atypical for apple!

  • I just got an iphone and I already have an itunes account for my ipod, but I need to sync my phone and I do not want all my music and apps on it, can I change setting on my pc with out hooking up my phone

    I just got an iphone 4s and I need to sync it to my itunes on my pc, but I do not want all the music and apps to be synced to my phone, can I change the settings in itunes with out hooking up my phone?

    Open itunes, connect iphone,select what you want, sync

  • Certain music pieces and apps won't download from my iPod to iTunes on my MacBook

    I want to put what is on my iPod on my new MacBook, but certain pieces and apps won't download because my computer isn't authorized (so it will delete it from my iPod if I sync), but when it asks me to authorize it it uses an old Apple ID that doesn't exist anymore and to which I do not have access. Any ideas how to fix this? I just want to be able to sync my iPod with this computer without worrying about losing anything.

    Check out this article:
    iOS: How to transfer or sync content to your computer
    Read the "iTunes and App Store Content" section, especially the "Transferring purchased content" link there.

  • I deleted my photos, music and apps. Help please!

    Help me please! I have deleted all my photos and music and apps. I think everything and it keeps saying I have something on phones and I really want to update my iphone. I'm on 2.7 GB Available. I don't know what to do?!

    If Other (the yellow bar) is too big something is corrupted.  The only solution (that I know of) is to restore from your most recent backup using iTunes (see http://support.apple.com/kb/ht1766).

  • I have deleted all photos, messages and apps but I still have no available space on my phone even though the applications don't add up to 12 GB.. Please help!!!

    I have deleted all photos, messages and apps but I still have no available space on my phone even though the applications don't add up to 12 GB.. Please help!!!

    You have data corruption.  restore your phone and set it up as a new device.  Not from backup

Maybe you are looking for

  • How do i know if my mac book is working on N speed

    I just bought the new airport extreme and there is a software that allow to change the configuration of the mac books from G speed to N. I check that i have that software installed, but i don't know how to make it work. I don't know if it is working

  • What version of imovie works with Snow?

    I have version 7.1.4 but it freezes on start up; I am just assuming its not the right one for Snow Leopard??

  • Where are partitioning a cube based on calmonth & fiscper

    Q1.where are partitioning a cube based on calmonth & fiscper ok In partitioning cube there are two types 1.physical partition & 2.logical partition so i want to know the both things and diferrences.

  • MPxIO-disk physical location in V890

    Hi All, How can I determine the slot position for a disk in a V890 when using MPxIO. The output from format is: 0. c4t200000186273C6A2d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848> /scsi_vhci/ssd@g200000186273c6a2 1. c4t200000186273D7CDd0 <SUN146G cyl 14

  • E-51. How to configure mail button to a "new txt m...

    Hi Guys, I have two Nokia E-51. In one phone the programable mail button was preset to "new txt message" on short press. I cannot program the same on my second set, because it does not give me option of "new text message" or "new mms" or "new e-mail"