Wie erstelle ich ein Exportstapelskript in Illustrator CS4?

7083
Timmy

Wie erstelle ich ein Batch-Skript, das einen Satz AI-Dateien in CS4 zu einem PNG bestimmter Größe exportiert?

1

2 Antworten auf die Frage

2
hyperslug

Sie sollten ein Skriptordner wie diese irgendwo haben: C:\Program Files\Adobe\Adobe Illustrator CS2\Presets\Scripts. Kopieren Sie die ExportDocsAsFlash.jsauf ExportDocsAsPNG24.jsund ändern Sie die Verwendung von AI Javascript Referenz als Leitfaden.

Ich habe dies mit CS2 versucht (Code unten), aber es scheint einen Fehler in der Engine zu geben. Bei PNGs (und anscheinend GIFs) greift es nicht auf nachfolgende Dokumentobjekte zu, sodass jedes Mal dasselbe Dokument gespeichert wird. Hoffentlich hat CS4 dies gepatcht.

var j, sourceDoc, targetFile;  var destFolder = null; // Get the destination to save the files destFolder = Folder.selectDialog( 'Select the folder where you want to save the exported files.', '~' );  if (destFolder != null) { for ( j = 0; j < app.documents.length; j++ ) { sourceDoc = app.documents[ j ]; // returns the document object  targetFile = getNewName(sourceDoc, destFolder);  // set PNG export options var opt = new ExportOptionsPNG24(); opt.antiAliasing = true; opt.transparency = true;  // Export sourceDoc.exportFile(targetFile, ExportType.PNG24, opt); } alert( 'Files are saved as PNG24 in ' + destFolder ); }  function getNewName(sourceDoc, destFolder) { var docName = sourceDoc.name; var ext = '.png'; // new extension for png file var newName = "";  // if name has no dot (and hence no extension, // just append the extension if (docName.indexOf('.') < 0) { newName = docName + ext; } else { var dot = docName.lastIndexOf('.'); newName += docName.substring(0, dot); newName += ext; }  // Create a file object to save the png saveInFile = new File( destFolder + '/' + newName ); return saveInFile; } 
1
s34d0

Sie können dies mit der Exportoption von inkscape tun.

Erstinstallation inkscape:

apt-get install inkscape 

Erstellen Sie ein export_to_png.shSkript mit dem folgenden Code:

#!/bin/bash for i in $(ls $1); do inkscape -w100 -h100 -e $1/$i.png $1/$i done 

Mach es ausführbar:

chmod +x export_to_png.sh 

Dann führe es aus:

./export_to_png.sh /path/to/images/ 

Es wird "somefile.ai" in "somefile.ai.png" mit einer Größe von 100x100 konvertieren.