Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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!
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.
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?
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.
Copy link to clipboard
Copied
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.
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!
Copy link to clipboard
Copied
Sorry that part of the Export process is not exposed to Scripting.
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.
Copy link to clipboard
Copied
try revising the script and setting these values under
function getPNGOptions()
{
pngExportOpts.verticalScale = 416.667;
pngExportOpts.horizontalScale = 416.667;
Copy link to clipboard
Copied
works for me
Copy link to clipboard
Copied
Hi, is it possible to activate only some layers before exporting?
Tks
Ivan
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
Copy link to clipboard
Copied
I am also looking for a 300ppi solution. Has anybody come across one yet?
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.
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
Copy link to clipboard
Copied
That line should read:
Copy link to clipboard
Copied
I want this script for converting into JPEG, please.
Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
Here is a another option w/ Acrobat Professional:
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.