Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

I have an Illustrator file that contains patterns. I'd like to export each pattern as an individual image to use in this new program that I'm trying called Sketch. Is there a batch processing script that exports layers as PNG or SVG? I'd like to have each geometric pattern available as a PNG, not as one large file.

Any thoughts?

png

share|improve this question

3 Answers 3

up vote 5 down vote accepted

If the patterns are indeed on individual layers, you may be able to use scripting to export each layer as an individual png.

Carlos Canto wrote a script for Illustrator and posted it in the Adobe forums.

In case of link rot, here's Carlos' script:

#target Illustrator

//  script.name = exportLayersAsCSS_PNGs.jsx;
//  script.description = mimics the Save for Web, export images as CSS Layers (images only);
//  script.requirements = an open document; tested with CS5 on Windows. 
//  script.parent = carlos canto // 05/24/13; All rights reseved
//  script.elegant = false;


/**
* export layers as PNG
* @author Niels Bosma
*/
// Adapted to export images as CSS Layers by CarlosCanto


if (app.documents.length>0) {
    main();
}
else alert('Cancelled by user');


function main() {
    var document = app.activeDocument;
    var afile = document.fullName;
    var filename = afile.name.split('.')[0];


    var folder = afile.parent.selectDlg("Export as CSS Layers (images only)...");


    if(folder != null)
    { 
        var activeABidx = document.artboards.getActiveArtboardIndex();
        var activeAB = document.artboards[activeABidx]; // get active AB        
        var abBounds = activeAB.artboardRect;// left, top, right, bottom


        showAllLayers();
        var docBounds = document.visibleBounds;
        activeAB.artboardRect = docBounds;


        var options = new ExportOptionsPNG24();
        options.antiAliasing = true;
        options.transparency = true;
        options.artBoardClipping = true;

        var n = document.layers.length;
        hideAllLayers ();
        for(var i=n-1, k=0; i>=0; i--, k++)
        {
            //hideAllLayers();
            var layer = document.layers[i];
            layer.visible = true;


            var file = new File(folder.fsName + '/' +filename+ '-' + k +".png");

            document.exportFile(file,ExportType.PNG24,options);
            layer.visible = false;
        }

        showAllLayers();
        activeAB.artboardRect = abBounds;
    }


    function hideAllLayers()
    {
        forEach(document.layers, function(layer) {
            layer.visible = false;
        });
    }


    function showAllLayers()
    {
        forEach(document.layers, function(layer) {
            layer.visible = true;
        }); 
    }


    function forEach(collection, fn)
    {
        var n = collection.length;
        for(var i=0; i<n; ++i)
        {
            fn(collection[i]);
        }
    }
}

Copy and paste this into a text file and save the text file with a .jsx suffix. Then place the .jsx file into Adobe Illustrator CS(x)/Presets/[your language]/Scripts. After relaunching Illustrator, the script should be visible via File > Scripts within Illustrator.

share|improve this answer
    
FYI, the script posted above doesn't work in Illustrator CC, it gives me: Error 8, Syntax error. Line 1: –  user22377 Apr 20 at 21:54
    
The script works absolutely fine in Illustrator CC here. –  Scott Apr 21 at 19:38
2  
I was also getting syntax error on line 1. When I reopened the .jsx there was additional code above the original line 1 from code above. I deleted everything above #target Illustrator saved the .jsx file. I relaunched Illustrator and the script works fine now. I am also using CC –  Marta Jul 23 at 0:24

For simplicity and speed of workflow, I would probably use the slice tool to create slices for the individual patterns, then Save for Web, making sure that "All Slices" was selected in the "Export:" dropdown. If I were building from scratch, I'd put each pattern on its own artboard (which you could still do) and use File>Export with the "Use Artboards" option checked.

share|improve this answer

Here you find the solution:

http://nucleodoillustrator.com/tag/exportar-camadas-em-psd/

Greets!

share|improve this answer
2  
Please try to summarize the solution posted. Answers that are only links don't help future visitors if the link breaks. Check out the help center for how to format acceptable answers. Welcome to GD!! –  ckpepper02 Jan 31 at 17:22

protected by Community Aug 15 at 12:02

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.