Export current document as jpeg with applescript

I am trying to script illustrator CS3 to export the current document as a jpeg file, to the same location as the current file was opened from, with the same filename, only changing the extension from .ai to .jpg, if a jpeg file already exists, it should overwrite the existing one...
the script should also save the current document, without closing it...
I have not been able to figure this out reading the illustrator applescript reference...
Any help would be appreciated...
-Rich

Hi Richard,
I'm not sure about Applescript, but i've found Illustrators export via javascript pretty crappy. I ended up exporting to PSD, launching photoshop and exporting our of photoshop via javascipt.
I hope someone tells me I am wrong.
Regards
Norbert

Similar Messages

  • Export current page to JGB with no confirmation?

    Hello,
    I'd like a script to export just the current page as a JPG to my desktop, with specific spec, without confirmation, with an automated filename (filename+date+time+".jpg").
    I've found one or two that export all pages, or have other needs, but nothing like this.
    My remote bosses like to see quick shots of pages I'm working on, but as they print a lot of them I'd like higher resolution than screen shots, which is how I'm doing it now. I can go the normal File>Export route, but that's too painful for the frequency and speed I need to fire these out. I just want to hit a keystroke which fires the script which results in a JPG on the desktop for me to jam into iChat.
    It would be too much to ask to have a keyline around the page, I suppose? Do dreams come true?
    I'm on CS5.5.
    Thank you for any help!

    Adjust "Export JPEG" options according to your needs (see comments).
    /* Copyright 2013, Kasyan Servetsky
    July 27, 2013
    Written by Kasyan Servetsky
    http://www.kasyan.ho.com.ua
    e-mail: [email protected] */
    //======================================================================================
    var scriptName = "Export current page to JPG - 1.0";
    Main();
    //===================================== FUNCTIONS  ======================================
    function Main() {
        if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
        var doc = app.activeDocument;
        if (app.activeWindow.constructor.name != "LayoutWindow") ErrorExit("Unable to get page number. Quit story editor.", true);
        var page = app.activeWindow.activePage;
        with (app.jpegExportPreferences) {
            exportingSpread = false;
            jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
            pageString = page.name;
            exportResolution = 300; // The export resolution expressed as a real number instead of an integer. (Range: 1.0 to 2400.0)
            antiAlias = true; //  If true, use anti-aliasing for text and vectors during export
            embedColorProfile = false; // True to embed the color profile, false otherwise
            jpegColorSpace = JpegColorSpaceEnum.RGB; // One of RGB, CMYK or GRAY
            jpegQuality = JPEGOptionsQuality.HIGH; // The compression quality: LOW / MEDIUM / HIGH / MAXIMUM
            jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING; // The rendering style: BASELINE_ENCODING or PROGRESSIVE_ENCODING
            simulateOverprint = false; // If true, simulates the effects of overprinting spot and process colors in the same way they would occur when printing
            useDocumentBleeds = false; // If true, uses the document's bleed settings in the exported JPEG.
        var fileName = doc.name.replace(/\.indd$/, "") + "_" + GetDate() + ".jpg";
        var file = new File("~/Desktop/" + fileName);
        doc.exportFile(ExportFormat.JPG, file);
    function GetDate() {
        var date = new Date();
        if ((date.getYear() - 100) < 10) {
            var year = "0" + new String((date.getYear() - 100));
        else {
            var year = new String((date.getYear() - 100));
        var dateString = (date.getMonth() + 1) + "-" + date.getDate() + "-" + year + "_" + date.getHours() + "-" + date.getMinutes() + "-" + date.getSeconds();
        return dateString;
    function ErrorExit(error, icon) {
        alert(error, scriptName, icon);
        exit();

  • How to determine the page count of the front document (pdf-Preview) with applescript?

    Hello, I'm a beinnger apple scripter, and I have 2 questions. First, im trying to find the code to generate a page count for the front document of preview. I tried something like this:
    choose file with prompt "Count the number of pages in this PDF file:" without invisibles
    do shell script "/usr/bin/mdls -name kMDItemNumberOfPages " & quoted form of POSIX path of result & " | /usr/bin/grep -o '[0-9]\\+$'"
    But I dont want to have to choose a file with the prompt, and Im not sure how to get the path or POSIX path of an open pdf that is the front document in prievew to then use that directory to select the file to run the shell script on. This is one step in a much larger sequence of automator/apple script commands for large print jobs.
    The large scale view is:
    1. seleting a group .musx Finale 2014 files and creating pdfs of all the documents
         -Achieved with Automator stuff: [Get selected finder items] [open finder items with Finale 2014] [run applescript to convert to pdf all the open files] (which I have working but without a proper repeat condition)
    2. sorting those those exports into even/odd groups
    3. making the even pages 2 up with a create booklet plugin
    3. combinging even/odd group pdfs in their respective folders
    4. sending the 2 up evens to 1 printer, and the singes to another printer.
    but at this stage in the code/automator this is what i'll need to be doing:
    1. Several pdf documents will be open and I need to determine the page count of the front document.
    2. With that result I need to determine if the pagecount is even or odd.
    3. If its even, I need to save as pdf in a file folder /desktop/PDF Export/Doubles
         - if its odd, I need to save as pdf pages from 1 to (pageCount -1) to /desktop/PDF Export/Doubles, and pages (pageCount) to (pageCount) to desktop/PDF Export/Singles. (example: A 5 page pdf will send pages 1-4 to folder "Doubles", and pages from 5 to 5 to Singles, A 1 page pdf will only send a copy to the folder "Singles." A 2 page pdf will send both pages to "doubles"
    4. once the even/odd pages have had pdfs made in the either or both of the folders, Im going to close the document and repeat for all other open pdfs.
    Which also brings me to my 2nd repeat condition question: how can I repeat (print, save as pdf, close) commands for open files and end the script once all files are closed? This can help me both at this stage, as well the coding stage before in creating the pdfs from open Finale/sibelius .sib/.musx files
    would it be something like this?:
    If front document exists
    try
    tell application "preview"
    <bla bla>
    end try
    end tell
    At stage 1 of the large scale i've gotten the files to export pdfs and close multiple files, but if i say "repeat 4 times" and i have 3 files it can do those commands but it gets stuck trying to repeat the code one more time. I need the repeat amount x to be the # of items in selection from the the original finder window.
    Thanks for the help!

    The following AppleScript will get the POSIX path and filename of the current PDF file. It will just return the integer value for page count. Note: The path retrieved is the actual path to the PDF file, unless it is on the Desktop. In the latter case, the path will be ~/Library/Containers/com.apple.Preview/Data/Desktop/filename.pdf.
    The script assumes that the following folders exist, otherwise you will need a try block to test for their presence.
    The AppleScript dictionary for Preview does not provide a page dictionary entry, that would make a repeat loop and page range possible for saving individual page ranges.
    set pdfDoubles to POSIX path of ((path to desktop) & "PDF Export" & Doubles)
    set pdfSingles to POSIX path of ((path to desktop) & "PDF Export" & Singles)
    tell application "Preview"
      -- gets quoted POSIX path and filename
              set pdfFile to (get path of front document)
              set pdfName to (get name of front document)
      log pdfName
              set cmdArg to "/usr/bin/mdls -name kMDItemNumberOfPages " & pdfFile ¬
                        & " | egrep -o \"(\\d+)\""
              set pageCnt to do shell script cmdArg
      display dialog pageCnt
              if pageCnt mod 2 is 0 then
      -- even
      -- save pdfName in pdfDoubles
              else
      -- save pdfName in pdfDoubles
      -- save individual pages in pdfSingles
              end if
    end tell

  • Why can't I export a document in PDF with working hyperlinks ?

    Hello everyone,
    I have a problem, just like everyone else, with Pages 5.
    I create a lot a documents that I export in PDF of course for sharing with my clients.
    The problem is that whenever I export one of those, the hyperlinks that I integrated in the Pages document just don't work in the PDF document! What a shame!
    Am I too stupid to find how to do that properly or did Apple suppressed even the hyperlinks in that version ?
    Thanks in advance for your helping answers.
    Best regard,
    Rémi

    Pages 5 only supports URL and email links.
    You can go back to Pages '09:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=432&mforum=iworktips ntrick
    For a full list of the Additions/removals and changes in Pages 5:
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&mforum=iworktipsn trick
    Review/rate Pages 5 in the App Store.
    Peter

  • How to export from CR2 to JPEG with GPS coordinates [LR5.7]

    I have CR2 files with GPS coordinates. During export to JPEG I lost GPS information. How to get JPEG's with GPS coordinates?

    See using lightroom 5.7.1 not all the meta-information is copied when exporting pictures

  • Crop jpegs with Applescript

    Hi can anyone please advise, I am wanting to crop jpgs using image handler and applescript.
    I am wanting to save (crop) only the right hand side off the original.
    I found the fllowing script came close but it crops to the centre not from the centre to the right can anyone advise?
    thanks.
    set this_file to choose file without invisibles
    set the vertical_crop to 0
    set the horizontal_crop to 0.50 -- 50%
    try
    tell application "Image Events"
    -- start the Image Events application
    launch
    -- open the image file
    set this_image to open this_file
    -- get dimensions of the image
    copy dimensions of this_image to {W, H}
    -- perform action
    crop this_image to dimensions {W - (W * horizontal_crop), H - (H * vertical_crop)}
    -- save the changes
    save this_image with icon
    -- purge the open image data
    close this_image
    end tell
    on error error_message
    display dialog error_message buttons {"Cancel"} default button 1
    end try

    Ok Guys I found a partial solution for anyone interested.
    As I stated in an earlier post I found Adobe Photoshop could do everything required such as scale,crop and save as jpeg etc.
    So I created a droplet from the action to perform this to my needs.
    I then installed Hazel <http://www.noodlesoft.com/hazel.php>
    This enabled me to watch a folder for files added, also creating a rule thats run the Photoshop droplet on items added to the watched folder.
    Everything processes just as I had hoped.
    The only downside is I need another license for Photoshop but the workflow works!
    I hope this update can help anyone else with a similar requirement.
    Many thanks again to Frank and particularly Neville for the help and advise offered without which I would have thrown my much loved MacBook out of the windows days ago!!

  • How would I export a text graphic jpeg with an alpha background?

    Hi,
    I made a simple text title and am trying to export it as a still frame jpeg and I can't get the export to have a alpha background? Any suggestions?
    (I am using this text title for a new website.)
    (I just got photoshop elements and don't know how to use it.)
    Thanks

    Np....
    http://discussions.apple.com/thread.jspa?threadID=1683723&tstart=0
    heres an excellent tip for exporting for alpha use... Tanks again Clint1459!

  • How to set "embed icc Profile" option  to export document as JPEG

    Hi All,
    While exporting the document as jpeg, through File->Export, there is an option "Embed ICC Profile" as figure shows.
    How to set it if I am exporting the document through my program in which I rasterize the document and used 
    the sAIImage->AsJPEG(raster, jpegDataFilter, params);
    I didn't find any option in AIRasterizeSettings or AIImageOptJPEGParams to set this flag.
    plz anyone suggest me how to do so.
    Thanks,
    Rud.

    thanks for you through out help.
    I use the folowing code which executing properly,but there is no effect on JPEG whether the value of jpegparam.s.jpeg.embedICCProfile is 0 or 1.
    /////Start
    ASOptimizationSettings jpegparam;
    jpegparam.fileFormat = asffJPEG;
    jpegparam.s.jpeg.embedICCProfile = isICCProfileEmbeded;
    ASInt32 optID;
    optID = sAIOptSet->GetUniqueOptimizationSettingsID();
    error = sAIOptSet->SetOptimizationSettings(optID, &jpegparam); // after executing this line error = 0
    /////End
    I guess it would  work when we export document as jpeg through AIActionManagerSuite
    not with  rasterizing the layer's art and then exporting them as JPEG  using AsJPEG().
    thanks

  • Exporting document as jpeg using kAIExportDocumentAction creating html file also

    hi,
    I used this action (kAIExportDocumentAction) to export the document as jpeg.And it is  creating a html file aslo.
    And also it not prompt the "JPEG Option" dialogbox. When I set the kDialogOff to kDialogON it shows first the" Export Dialog" .
    is there any way to get only "Jpeg Option" dialog box while exporting through this action?
    plz Help!!!
    here are the code ....
    ai::FilePath filePath(ai::UnicodeString("C:\\Documents and Settings\\rudreshp\\Desktop\\Export\\rudresh\\hi.jpeg"));
    AIActionParamValueRef actionParam;
    //create a new action param value.
    sAIActionManager->AINewActionParamValue(&actionParam);
    //include the path where to save
    error = sAIActionManager->AIActionSetStringUS(actionParam, kAIExportDocumentNameKey, filePath.GetFullPath() );
    error = sAIActionManager->AIActionSetString(actionParam, kAIExportDocumentFormatKey, "JPEG file format");
    error = sAIActionManager->AIActionSetString(actionParam, kAIExportDocumentExtensionKey, "jpg");
    error = sAIActionManager->AIActionSetBoolean(actionParam, kAIExportDocumentSaveMultipleArtboardsKey, false);
    error = sAIActionManager->PlayActionEvent(kAIExportDocumentAction,  kDialogOff,  actionParam);
    //delete the actionParam
    error = sAIActionManager->AIDeleteActionParamValue(actionParam);

    The export document action is an action for exporting the doument as you have seen, it is not a Export Jpeg action.
    So, no it is not possible with the export action.

  • Export PDF Workflow with Applescript and CS3

    Hello,
    I am setting up some PDF workflow with Applescript.
    On a given moment, as my script runs and after getting some user-input answers to questions in some dialogs, my script tells InDesign CS3 to open the Export Adobe PDF window for the current document. I copied and pasted that small part of the script:
    tell application "Adobe InDesign CS3"
    tell document 1
    export format PDF type to "Macintosh_HD:Test01.pdf" using "somePreset" with showing options
    end tell
    end tell
    When you run this small part of my Applescript, InDesign opens the Export Adobe PDF window (as expected) waiting for me to click on "Export". That is exactly what I want, since the user is given here a last opportunity to change some values (for example page range, or spreads). When all is set, the user can click on Export to close the dialog and finish the script.
    Problem: I was hoping that the Adobe PDF Preset "somePreset" would be selected in the first pull-down menu of the Export Adobe PDF window when this window is opened by the script. Unfortunately the last used preset is always selected by default. Anyone suggestions or help?
    Kind regards,
    Bertus Bolknak.

    My operators enter the page range and filename into a dialog box. Then I set those in the script. I use the Press Quality preset to start with and then set the changes I want into a export variable. I set things like bleed, marks, page range, etc.
    Here is an example:
    set theProps to properties of PDF export preset "[Press Quality]"
    try
    delete PDF export preset "Schmidt PDF"
    end try
    set theStyle to {name:"Schmidt PDF", acrobat compatibility:acrobat 7, bleed top:"0.125i", bleed bottom:"0.125i", bleed inside:"0.125i", bleed outside:"0.125i", page marks offset:"0.125i", include ICC profiles:Include None, effective PDF destination profile:use no profile, effective PDF X profile:"No Color Conversion"} & theProps
    make PDF export preset with properties theStyle
    set properties of PDF export preferences to theStyle
    set color bitmap sampling of PDF export preferences to none
    set grayscale bitmap sampling of PDF export preferences to none
    set page range of PDF export preferences to (item i of myPageList) as string
    export document 1 format PDF type to (PrinergyFolder & myJobNumFinal & "_" & VerCode & ".pdf") as Unicode text without showing options
    I am also doing this in Quark.

  • I can't seem to "close" my documents on MSoft Word with AppleScript!

    Hi
    I have tons of documents open on MSoft Word and wish to close some of them. Luckily, those that I wish to close all start with the word "book", so I was thinking I could actually automate that with AppleScript hence avoid closing them one by one.
    I wrote the following code:
    tell application "Microsoft Word"
    count (document)
              set countresult to result
              repeat with incrementValue from 1 to countresult
                        if name of document incrementValue starts with "book" then
      activate document
      close document
                        end if
              end repeat
    end tell
    To my surprise, it didn't work!
    I got the following under "Replies", which showed that AppleScript did indeed try to close the document that starts with "book":
    tell application "Microsoft Word"
    count every document of current application
      --> 6
    get name of document 1
      --> "book_mac_OS_X_and_iOS_internals.htm"
    activate
    close document
    get name of document 2
      --> "applicable books.htm"
    get name of document 3
      --> "What Do You Want Homespace to Do.htm"
    get name of document 4
      --> "URL_repository_for_outcomes.htm"
    get name of document 5
      --> "SYNTHESIS - History a Step Back.docx"
    get name of document 6
      --> "SYNTHESIS - History a Step Back.docx"
    end tell
    But when I went back to Word, I still saw the document there!
    I actually added an additional line (I didn't include the code in that which I pasted here) asking to count the number of documents in Word AFTER the so-called "close", and the number remains 6.
    Can anyone enlighten me on this?
    Regards,
    junxiang99

    Hi,
    The quickest way to do this (tested with OS 10.8.2, MS Word 2011) is in one line:
    tell application "Microsoft Word" to close every document whose name begins with "book"
    The reason why your script doesn't work is that you aren't specifying to Word which document you want it to close.
    So, changing one line ought to do it:
    close document incrementvalue -- instead of "close document"
    But... when you close a document, you change the document count. Document 2 becomes document 1, document 3 becomes document 2 etc. So eventually you'd get a message saying "The object you are trying to access doesn't exist".
    Because of this, if you want to do it in a repeat loop, you have to work backwards:
    tell application "Microsoft Word"
      set doc_count to count documents
      repeat with x from doc_count to 1 by -1
      if name of document x begins with "book" then close document x
      end repeat
    end tell
    Hope this helps.

  • IPhoto Exporting "Current" Edited Jpeg

    Hi,
    I have tried to search for an answer regarding the export in "Current" option in iPhoto and have not yet completely understand the option.
    The background is that since the photos app is coming out soon, I am thinking about exporting all my edited jpegs and put them in the photos library. Hence i will be using photos exclusively as a management software whereas i will be using Lightroom to do my edits from now on since I have transitioned to shooting raw files. The problem I have encountered during exporting in jpeg is that the high quality file seems to small in size while the maximum quality seems to big compared to the original file. I understand that what iPhoto does is re-package the photo in it's own algorithm hence it's not really comparable to the original file. However, I've noticed that one you've done edits to a jpeg, exporting in "current" file gives you a edited jpeg with comparable size to the original file.
    My question is if this current edited file is of same quality as the original file and hence i don't have to make the tough decision on whether i want to export in high or maximum quality.
    Thank you very much.

    but the reason for doing so is i want to keep Photos library as clean as possible.
    Seriously, you need to ask yourself, what on earth is a "dirty" Photos Library? That concept makes no sense to me.
    I am simply planning to use photos as a managing software to create events etc for future browsing. No edits whatsoever will be done in the photos app since editing yields you a duplicate of almost the same size which takes up significant amount of space
    If that's ll you're doing you don't need - and should not use - a photo manager design specifically for non-destructive editing. It's only adding layers of complexity to your workflow. Just keep you photos in folders and use an image browser.
    Plus, I have basically migrated towards taking RAW files
    That makes even less sense. You cannot do anything with a Raw without first processing it into something else - like a Jog. You can't view it, print it, anything. You're idea is not quite thought through.

  • Can not add function to pages-document created with Applescript

    If I create new document using the GUI (New document) I can place the cursor within any table-cell, type "=" (equal sign) and f.e. "2+2" which will result in a cell showing a "4".
    If I create a document with Applescript, I can not add new functions (neither by typing = nor by using Insert >> Function (may be different, I have German version here). Already existing functions (which already were in the template) can still be used and work as expected but can not be altered.
    Any idea?
    I use Pages '08, Version 3.03
    Code I used to create the document:
    tell application "Pages"
    launch
    make new document at front with properties {template name:templateName}
    # Angebotsnummer ins Dokument schreiben
    tell body text of front document
    make new paragraph at after paragraph 1 with data angebotsNr
    set paragraph style of paragraph 2 to "Überschrift"
    end tell
    # Datei abspeichern
    set dateiName to missing value
    repeat until dateiName is not equal to missing value
    set dateiName to text returned of (display dialog "Datei Name:" default answer angebotsNr & "_" & kundenName) as text
    end repeat
    save front document in angebotsOrdner & dateiName
    end tell

    I apologize but the given script can't run.
    The variable templateName is undefined.
    The variable angebotsNr is undefined too.
    About the described behavior, it's a bug which I never discover before.
    It's always striking in Pages '09.
    Here is the report which I filed :
    Bug ID# 8704270
    Summary:
    +Odd behavior of tables in Pages documents created by a script+
    +Steps to Reproduce:+
    +Run this huge script+
    +tell application "Pages"+
    +make new document at front with properties {template name:"Blank"} (* "Vierge" on French systems *)+
    +end tell+
    +Insert a table+
    +try to insert a formula+
    +Expected Results:+
    +I assumed that I will get the formula editor which I get when the document is created by hand+
    +Actual Results:+
    +There is no way to get the editor, no way to insert the equal character.+
    +This odd behavior strike in all versions of Pages '09 and Pages '08+
    Regression:
    +None to my knowledge+
    Yvan KOENIG (VALLAURIS, France) dimanche 28 novembre 2010 11:30:29

  • The colour swatch 'black' has a conflict with the current document?

    I have created some graphic styles and saved them as the manual explains.
    When using them in a new document I keep getting the conflict window asking if I wish to merge swatches.
    What have I done to keep getting this unwanted conflict message?

    Yeah, *real* annoying. This is something new. It didn't happen before in CS5, at least not to me and I always work with global colors.
    Example:
    No matter what object, no matter what color (even without any color!), upon paste I get the merge dialog: The color swatch "K=30" has a conflict with the current document.
    When I delete the swatch and then cut something (not having that color) I get: The color swatch "Deleted Global Color" has a conflict with the current document.
    Does anyone have a solution to this problem?
    This is driving me nuts.

  • When I publish a SWF/HTML5 module with Captivate 8 and try to run it using IE9 - I get the following error "The content you are viewing is not supported in the current Document Mode" - anyone know why?

    When I publish a SWF/HTML5 module with Captivate 8 and try to run it using IE9 - I get the following error "The content you are viewing is not supported in the current Document Mode" - anyone know why?

    TLCMediaDesign wrote:
    I've seen a lot of threads about getting rid of these kind of messages. Those messages are there for a reason most of the time. If you have CSS animations or other HTML5 standards that cannot be rendered in IE9 they won't magically start working becuse you got rid of a message. I use IE9 since that is the minimum standard for the client. I have never seen that message publishing to HTML5 content.
    IMO, if your client has IE9 I think that you should develop with IE9 in mind not IE11.
    When you say "develop with IE9 in mind not IE11" do you mean use SWF instead of HTML5? I used the standard question types, and a converted PowerPoint presentation. I didn't add anything out of the ordinary.

Maybe you are looking for

  • Getting an error "Customer could not be determined" for IDOCs in SCM 7.0

    Hi Friends,     I am executing the report RSMIPROACT in ECC 6.0 system to publish Demand and Stocks into the SCM 7.0 system. The IDOC is processed without any errors in ECC 6.0 . However, in the SCM 7.0 system , the IDOC fails with the error. I have

  • New OS has locked up my playbook

    I just downloaded the new OS 2.0 and my playbook has locked up on reboot. When it finally starts up I get the home screen but nothing works. When I manage to get into the OS hardware settings I see that I only have only 29.5 mb of memory available of

  • Video thumbnails in organizer

         I cannot see the thumbnails for my mpeg files in organizer.  why?

  • What is the use of BI ACCELERATOR

    What is the use of BI ACCELERATOR

  • Help!  Business Area/Report

    Hi all, I am wondering if it is possible to create this scenerio: To have 1 business area with Object A To have one report with object A available to end user To have another report with object A hidden to end user I know this is possible to do by ha