Copy link to clipboard
Copied
Hello, I want to convert small SVG icon (2kb) to EPS. But after conversion the EPS file is too large. Any idea whats wrong in my script?
Thanks.
var folder = Folder.selectDialog("Select Source Folder..."); // select folder
if (folder==null) {
alert("Good Bye");
}
else {
var files = find_files (folder, ['.svg']);
var fileCount = files.length; // count them
if (fileCount>0) {
for (i=0; i<fileCount; i++) {
var idoc = app.open(files);
var epsOptions = new EPSSaveOptions();
var currentDoc = activeDocument;
var epsFile = new File (currentDoc.fullName);
epsOptions.cmykPostscript = true;
epsOptions.compatability = Compatibility.ILLUSTRATOR8;
epsOptions.compatibleGradientPrinting = true;
epsOptions.embedAllFonts = true;
epsOptions.embedLinkedFiles = true;
epsOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
epsOptions.includeDocumentThumbnials = false;
epsOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT;
epsOptions.postScript = EPSPostScriptLevelEnum.LEVEL2;
epsOptions.preview = EPSPreview.COLORTIFF;
currentDoc.saveAs (epsFile, epsOptions);
idoc.close();
}
alert(fileCount + ' file(s) processed');
}
else {
alert("There are no Illustrator files in this folder.");
}
}
// recurse subfolders - Peter Kharel
function find_files (dir, mask_array){
var arr = [];
for (var i = 0; i < mask_array.length; i++){
arr = arr.concat (find_files_sub (dir, [], mask_array.toUpperCase()));
}
return arr;
}
function find_files_sub (dir, array, mask){
var f = Folder (dir).getFiles ( '*.*' );
for (var i = 0; i < f.length; i++){
if (f instanceof Folder){
find_files_sub (f, array, mask);
} else if (f.name.substr (-mask.length).toUpperCase() == mask){
array.push (f);
}
}
return array;
}
Oh, Wait...you made a mistake in you code at line 23 :
epsOptions.compatability = Compatibility.ILLUSTRATOR8;
It should be:
epsOptions.compatibility = Compatibility.ILLUSTRATOR8;
Copy link to clipboard
Copied
EPS is a specific format which will embed two sets of data. One is for every single app but illustrator that will open the eps file (including converted elements) and the other is for Illustrator as it will preserve special effects and native features.
That may explain the bump in size.
Copy link to clipboard
Copied
What do you mean by "too" large?
And if there are linked images in the icon by any chance, your options at the moment specify embedding. If that's the case, keep them linked?
Oh, here's a reason why you may experience a 'shocking' jump in file size. An SVG is an XML text document which is interpreted by Illustrator in a different way than most other documents that it opens.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
<circle fill="#FFFF00" stroke="#000000" stroke-miterlimit="10" cx="100.8" cy="105.7" r="64.1"/>
</svg>
When Illustrator opens the SVG file, it makes the document structure its 'own' and re-creates the XML into Illustrator shapes, layers, etc. When you open a raw SVG and save it with Illustrator, you can use the "Preserve the Illustrator capabilities" checkbox to see what other great things AI will stick into the file.
When I did this with the above SVG code, it went from 6 lines of code to 1961 lines of code. A big increase. Now, as Loic said, when you save out an EPS from this, it would put the Illustrator part and the EPS part into the file. You're getting plenty of overhead, but that's the nature of EPS, I guess.
Here's our comparison:
Original SVG: 1K (6 lines)
Illustrator-Editable SVG: 146K (1961 lines)
Exported EPS: 405K (25847 lines)
Copy link to clipboard
Copied
Too large I meant too BIG in file size.
2 kb SVG and I use manual "Save As" with this configuration. Final EPS size only 52 kb. So, I want to know how to implement this configuration to my script. Thanks
Copy link to clipboard
Copied
Oh, Wait...you made a mistake in you code at line 23 :
epsOptions.compatability = Compatibility.ILLUSTRATOR8;
It should be:
epsOptions.compatibility = Compatibility.ILLUSTRATOR8;
Copy link to clipboard
Copied
thank you, you save my day