• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Batch Export as PNG

New Here ,
Mar 11, 2009 Mar 11, 2009

Copy link to clipboard

Copied

Hello, i'm having dreadful trouble exporting a batch of AIs to PNG (using illustrator CS4).

It seemed really obvious to record export>PNG>relevant setting as an action and then run that on the whole folder.

The trouble is that the action, when run as a batch (and only when run as a batch) skips the whole export step. it open the AI fine, runs through the action very quickly, and then fails to write the PNG.

what's more, i also tried this on a colleagues machine and his did exactly the same, so i'm thinking that it's me missing something obvious.

as a workaround i turned the dialogues on, but this kind of defeats the object.

any help would be very greatly appreciated.

cheers
Jez

Views

50.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Contributor ,
Mar 11, 2009 Mar 11, 2009

Copy link to clipboard

Copied

Well I do not know the status of the art but if they could be place in one document on multiple artboards then the solution is easy you d o not need to batch a simple export allows you to export all the art boards and individual png files all in one export operation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2009 Mar 16, 2009

Copy link to clipboard

Copied

Jez,

I'm having the same problem. It skips the export action. I was able to make it work in CS3, but the files are CS4.

Wade, thanks for your suggest. In this case that is not an option.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2009 Mar 17, 2009

Copy link to clipboard

Copied

It's probably possible to do this with a script. If you're interested, contact me by email.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Has anyone been able to figure out a solution to this. I have about 200 logos that I need to export as PNG files, and I REALLY don't want to have to do this one by one. Any advice would be MUCH appreciated.

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

You might try this

/**********************************************************

ADOBE SYSTEMS INCORPORATED
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved

NOTICE:  Adobe permits you to use, modify, and
distribute this file in accordance with the terms
of the Adobe license agreement accompanying it. 
If you have received this file from a source
other than Adobe, then your use, modification,
or distribution of it requires the prior
written permission of Adobe.

*********************************************************/

/**********************************************************

ExportDocsAsPNG24.jsx

DESCRIPTION

This sample gets files specified by the user from the
selected folder and batch processes them and saves them
as PDFs in the user desired destination with the same
file name.

**********************************************************/

// Main Code [Execution of script begins here]

// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pngExportOpts;

// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' );

// If a valid folder is selected
if ( sourceFolder != null )
{
    files = new Array();
    fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
   
    // Get all files matching the pattern
    files = sourceFolder.getFiles( fileType );
   
    if ( files.length > 0 )
    {
        // Get the destination to save the files
        destFolder = Folder.selectDialog( 'Select the folder where you want to save the converted PNG files.', '~' );
        for ( i = 0; i < files.length; i++ )
        {
            sourceDoc = app.open(files); // returns the document object
                                   
            // Call function getNewName to get the name and file to save the pdf
            targetFile = getNewName();
           
            // Call function getPNGOptions get the PNGExportOptions for the files
            pngExportOpts = getPNGOptions();
           
            // Export as PNG
            sourceDoc.exportFile( targetFile, ExportType.PNG24, pngExportOpts );
           
            sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
        }
        alert( 'Files are saved as PNG in ' + destFolder );
    }
    else
    {
        alert( 'No matching files found' );
    }
}


/*********************************************************

getNewName: Function to get the new file name. The primary
name is the same as the source file.

**********************************************************/

function getNewName()
{
    var ext, docName, newName, saveInFile, docName;
    docName = sourceDoc.name;
    ext = '.png'; // new extension for png file
    newName = "";
       
    for ( var i = 0 ; docName != "." ; i++ )
    {
        newName += docName;
    }
    newName += ext; // full png name of the file
   
    // Create a file object to save the png
    saveInFile = new File( destFolder + '/' + newName );

    return saveInFile;
}


/*********************************************************

getPNGOptions: Function to set the PNG saving options of the
files using the PDFSaveOptions object.

**********************************************************/

function getPNGOptions()
{
   
    // Create the PDFSaveOptions object to set the PDF options
    var pngExportOpts = new ExportOptionsPNG24();
   
   
   
    // Setting PNGExportOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    // Add more properties here if you like
    pngExportOpts.antiAliasing = true;
    pngExportOpts.artBoardClipping = false;
    //pngExportOpts.horizontalScale = 100.0;
    //pngExportOpts.matte = true;
    //pngExportOpts.matteColor = 0, 0, 0;
    pngExportOpts.saveAsHTML = false;
    pngExportOpts.transparency = true;
    //pngExportOpts.verticalScale = 100.0;

    return pngExportOpts;
}

Copy into a text editor and save as a .jsx file and place in the presets>scripts folder.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Thanks, Larry.

which segment of code do i need to copy?  I wasn't sure. Also, I pasted into text edit and Word....neither will let me save as a .jsx. Any suggestions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Copy everything except what I obviously wrote. Paste into text edit and save as a .txt file. Re-do the extension to .jsx, it just has to be a .jsx file to be recognized as a JavaScript. Read the documentation at the top to get an idea of what is supposed to happen.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Ok.....i did what you said, but it's not working.....i double clicked my .jsx file and discovered ExtendScript Toolkit. I attached a screenshot of what I pasted. I'm not sure it's right.

Also, how do I execute a script on a whole folder through Illustrator?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

You don't double-click a script file. Glad you found the ExtendScript application. Did you put the .jsx file in the presets/scripts folder? Once it is there, restart AI and run the file from File>Scripts. You should get a list of the files in the scripts folder. Select the ExportDocsAsPNG24 and click once. It should ask you for a folder of files to save and a destination folder to save them to.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Ok....wait. I didn't paste enough of the code, I looked at the other scripts already in there and saw what i did wrong. So....I was able to use the script to batch PNG, BUT....I need hi-res PNG files. Is there a way to modify the script to make it hi-res to use in Word, PPT, etc...I know...ew, but I have to. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Sorry that part of the Export process is not exposed to Scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2009 May 22, 2009

Copy link to clipboard

Copied

This problem is annoying.  I'm having the same issue as pikwi

Let me know if you find a solution.  I'm going to continue to try and solve this problem.  I'll post if I find something.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2009 May 22, 2009

Copy link to clipboard

Copied

try revising the script and setting these values under

function getPNGOptions()

{

    pngExportOpts.verticalScale = 416.667;

    pngExportOpts.horizontalScale = 416.667;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2009 May 22, 2009

Copy link to clipboard

Copied

works for me

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2015 Jun 15, 2015

Copy link to clipboard

Copied

Hi, is it possible to activate only some layers before exporting?

Tks

Ivan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 12, 2016 Aug 12, 2016

Copy link to clipboard

Copied

The script is very useful. Thank you very march.

I have the same question as some others here. How exactly to change the script to get PNGs with a certain definition?

I'd like to export my art boards to PNGs with 300ppi as I can do it with the intern export command where I can choose certain resolution

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

I am also looking for a 300ppi solution. Has anybody come across one yet?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

Try to create an Action that exports as 300 ppi PNG and use the Batch option from the Actions panel to automate the export.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 07, 2020 Jan 07, 2020

Copy link to clipboard

Copied

I'm able to start the script within Illustrator, but I get the following error

"Error 1242: Illegal argument-argument 1

-File/folder expected

Line 55 Source Doc=app.open(files); //retruns the document object"

What am I doing wrong?

I'm trying to run the script through Adobe Illustrator's File>Script>Other Script

Suggestions?

Thanks

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 13, 2020 Jan 13, 2020

Copy link to clipboard

Copied

That line should read:

sourceDoc = app.open(files[i]);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2020 Apr 15, 2020

Copy link to clipboard

Copied

I want this script for converting into JPEG, please.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

LATEST

Thank you for the script. I was having the same problem and was relieved to find a solution. Unfortunately, when I run the script from Illustrator, the program freezes. We have CS6 here. I let it run for a while (at least a half hour for only 5 files), but it just hangs until I click something and then says "Not Responding." Am I missing something?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 29, 2010 Jan 29, 2010

Copy link to clipboard

Copied

You've probably already found a work around since this post was back in March - but for future people who have just run into the same issue/bug (as *I* just did) - I've accomplished the goal of going from Illustrator EPS > PNG by creating a batch action to export to PSD as a first step - and then a second action (in photoshop) to go from PSD > PNG. 

It's an extra step, but much faster than doing each file individually.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2010 Mar 31, 2010

Copy link to clipboard

Copied

Here is a another option w/ Acrobat Professional:

  1. File > Combine > Merge Files into a Single PDF
  2. Add Files > Select your Illustrator files (yes, *.ai )
  3. Combine Files (bottom right corner)
  4. Save your PDF

Now you have this PDF file where each page is one of those AI files you want to batch convert to a medium/high-res PNG.

  1. File > Export > Image > PNG
  2. Settings <- important! (it's next to the format drop down menu at the bottom of the dialogue box)
  3. You can type the target resolution or select from the options available
  4. OK
  5. Save

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines