5 Replies Latest reply on Feb 7, 2017 5:12 PM by azisher

    SVG to EPS file is too large

    azisher

      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[i]);
      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[i].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[i] instanceof Folder){
      
      
                  find_files_sub (f[i], array, mask);
      
      
              } else if (f[i].name.substr (-mask.length).toUpperCase() == mask){
      
      
                  array.push (f[i]);
      
      
              }
      
      
          }
      
      
          return array;
      
      
      }
      
        • 1. Re: SVG to EPS file is too large
          Loic.Aigon Adobe Community Professional

          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.

          • 2. Re: SVG to EPS file is too large
            Silly-V Adobe Community Professional

            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)

            • 3. Re: SVG to EPS file is too large
              azisher Level 1

              Too large I meant too BIG in file size.

              Screenshot_59.jpg

               

              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

              • 4. Re: SVG to EPS file is too large
                moluapple Level 4

                Oh, Wait...you made a mistake in you code at line 23 :

                    epsOptions.compatability = Compatibility.ILLUSTRATOR8;   

                It should be:

                    epsOptions.compatibility = Compatibility.ILLUSTRATOR8;

                1 person found this helpful
                • 5. Re: SVG to EPS file is too large
                  azisher Level 1

                  thank you, you save my day