LinearAndLoom Icons

Batch Convert EPS to JPG in Illustrator (Free Script)

Free Adobe Illustrator script that exports a JPG for every EPS file in a folder at 300 DPI or any resolution, keeping the same file names.

Download illustrator-batch-eps-to-jpg.jsxJavaScript (ExtendScript) · 104 lines · 3 KB · free

Stock sites, marketplaces and clients usually want a JPG preview next to each vector file. Illustrator's export dialog handles one file at a time. This script exports a JPG for every EPS in a folder, at the resolution you choose.

What it does

How to use it

  1. Run the script in Illustrator (see below).
  2. Choose the folder that holds the EPS files.
  3. Type a resolution and click OK, or just click OK for 300 DPI.
  4. Wait for the "Conversion finished" message.

How to run an Illustrator script

  1. Download the script with the button on this page.
  2. Open Adobe Illustrator. No document needs to be open.
  3. Go to File > Scripts > Other Script... (Ctrl+F12 on Windows, Cmd+F12 on Mac).
  4. Choose the downloaded .jsx file.

To keep the script in the menu, copy it into Illustrator's Presets > en_US > Scripts folder inside the Illustrator application folder and restart Illustrator. It then appears under File > Scripts.

Illustrator may warn that scripts can change your files. That is normal for any script. This one's full code is shown at the bottom of the page so you can read what it does.

Which resolution should you choose?

Illustrator cannot scale a JPG export beyond about 558 DPI, so higher values are capped there. For a very large artboard, a high DPI creates an enormous image and may fail. Use 72 in that case.

Next step

To pack each EPS with its JPG into one ZIP, run the zip EPS and JPG pairs script on the same folder.

Questions

Does it convert files in subfolders?

No, only the EPS files directly inside the folder you choose.

Can it export PNG instead?

Not as written. The script uses Illustrator's JPEG export.

Why is the background white?

JPG has no transparency, so empty areas of the artboard become white.

The code

This is the complete script. Nothing else is downloaded or installed.

// illustrator-batch-eps-to-jpg.jsx
// Free script from LinearAndLoom Icons: https://linearandloomicons.netlify.app/scripts/
// Provided as is. Try it on a copy of your files first.

/*  EPS to JPG - Adobe Illustrator script
    ------------------------------------------------------------
    Converts every .eps file in a folder to a JPG at the resolution you choose (300 DPI by default).
    JPGs are saved next to the EPS files with the same names, including names with spaces.
    Original EPS files are never modified.

    HOW TO RUN
      Illustrator: File > Scripts > Other Script... > choose this file.
      1. Pick the folder that contains the .eps files.
      2. Type the resolution, or press OK for 300 DPI.
*/
#target illustrator

function convertEPStoJPG() {
    var inputFolder = Folder.selectDialog("Select folder with EPS files");
    if (!inputFolder) return;

    var dpi = prompt("Enter output resolution (DPI):", "300");
    if (dpi === null) return;

    dpi = parseFloat(dpi);
    if (isNaN(dpi) || dpi <= 0) dpi = 300;

    var epsFiles = inputFolder.getFiles(/\.eps$/i);

    if (epsFiles.length === 0) {
        alert("No EPS files found.");
        return;
    }

    var successCount = 0;
    var errorCount = 0;

    var originalUserLevel = app.userInteractionLevel;
    app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

    for (var i = 0; i < epsFiles.length; i++) {
        var epsFile = epsFiles[i];
        var doc = null;

        try {
            doc = app.open(epsFile);

            if (doc.documentColorSpace != DocumentColorSpace.RGB) {
                doc.documentColorSpace = DocumentColorSpace.RGB;
            }

            var scale = (dpi / 72) * 100;
            // Illustrator's JPEG export cannot scale above 776.19 % (about 558 DPI)
            if (scale > 776.19) { scale = 776.19; }

            var jpegOptions = new ExportOptionsJPEG();
            jpegOptions.quality = 100;
            jpegOptions.horizontalScale = scale;
            jpegOptions.verticalScale = scale;
            jpegOptions.optimization = true;
            jpegOptions.embedColorProfile = true;
            jpegOptions.antiAliasing = true;
            jpegOptions.artBoardClipping = true;

            // original filename without extension
            var originalName = epsFile.displayName.replace(/\.eps$/i, "");
            
            // Illustrator will create dashed filename
            var dashedName = originalName.replace(/ /g, "-");

            var tempJpgFile = new File(inputFolder.fsName + "/" + dashedName + ".jpg");

            // export
            doc.exportFile(tempJpgFile, ExportType.JPEG, jpegOptions);

            // rename back to original with spaces
            tempJpgFile.rename(originalName + ".jpg");

            successCount++;
            doc.close(SaveOptions.DONOTSAVECHANGES);

        } catch (e) {
            errorCount++;

            if (doc) {
                try {
                    doc.close(SaveOptions.DONOTSAVECHANGES);
                } catch (err) {}
            }

            $.writeln("Error: " + epsFile.name + " -> " + e.toString());
        }
    }

    app.userInteractionLevel = originalUserLevel;

    alert(
        "Conversion finished.\n" +
        "Successful: " + successCount + "\n" +
        "Errors: " + errorCount
    );
}

convertEPStoJPG();

Download illustrator-batch-eps-to-jpg.jsxJavaScript (ExtendScript) · 104 lines · 3 KB · free

These scripts are free. If one saved you time, you can say thanks by buying a pack from the LinearAndLoom Etsy shop.

More scripts