Artwork Automation

Too many layers, too little time

The client uses vector drawings for many of the product colorways in catalog, hundreds of them in fact. Getting all those little vectors sized and ready for a print catalog was a hassle. It was tough on the product development side and it was challenging on the catalog production end.

I worked with the product managers that gathered the vector files, the ones that they used for apparel manufacturing, to streamline the process of creating the colorways. We created an Adobe Illustrator template that they could use. Each product was placed on a layer and named according to the established convention. This reduced errors in the correct naming of colors and gave the product manager control of the naming.

 

Scripting for Adobe

With this template setup, I wrote a script that exported each layer of the Illustrator file and renamed it combining the file name, which we named with the product SKU and the layer name (color name and angle).

Extracting Layers from an Illustrator File

This script cycles through a group of illustrator files exporting the visible, unlocked layers to psd files for print. Since many of the color ways for the line guides came as CAD drawings exported to vectors, this sped up preparing those vectors for use in the print catalog. The apparel designer just needed to name the layers consistently and the script works like a charm.

Note: The syntax highlighting gets a little confused, but the script should work fine. This was written before Adobe CC, so I don’t know if there have been API changes since then.

	
// ExtractLayers.1.2.0
// 2013 Ashton Watkins 
//with help from the MultiExporter script by Matthew Ericson



var destFolder, sourceFolder, files, fileType, saveOpts, app, docu;
var J = 0;

// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want', '~' );

// If a valid folder is selected
if ( sourceFolder != null )
{
    files = new Array();
    fileType = '*.ai';
	//fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
    files = sourceFolder.getFiles( fileType);    
    if ( files.length > 0 ){
        destFolder = Folder.selectDialog( 'Select the folder where you want to save the layers.', '~' );  
        batchFiles();
    } 
 }
    
    
 // Get all files matching the pattern  
 function batchFiles(){   
     app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
	 if(files.length > J){
     docu  = app.open(files[J]); // returns the document object
		//alert(J);
	  processLayers(docu); //sends docment object to the function 
      }
 }//close if source
           
                    
 function processLayers(docu){
     var doc = docu;
     // Create the illusrtratorSaveOptions object to set the AI options
						
                       saveOpt = saveOptFunc();
					 var export_type = ExportType.PHOTOSHOP;	
						
                        if (doc.saved==false) doc.save();
                        
					// if the layer isn't locked, then turn make it invisible - sets up for the next loop
                        for (i=0; i<doc.layers.length; i++){
                            if (doc.layers[i].locked == false) doc.layers[i].visible = false;
							}
                        
					 fullDocName = doc.fullName;
                        var param = doc.name.split(".");
                        realDocName = param[0];
                        
					 // this is where the magic happens - cycle through the unlocked layers and export each one to a psd file	
                        for (i=0; i<doc.layers.length; i++) {
                            if (i-1<0) doc.layers[i].visible = true;
                            else {
                                doc.layers[i-1].visible = false;
                                doc.layers[i].visible = true;
                            }
                            if (doc.layers[i].locked == false) {    
                                  
							docName = realDocName+doc.layers[i].name;
                                //var saveName = new File ( destFolder + '/' + docName );
								var destFile = new File(destFolder + '/' + docName +'.psd');	
                                doc.exportFile( destFile, export_type, saveOpt );
							
                            }
                        }//for loop
                        doc.close(SaveOptions.DONOTSAVECHANGES);
			//if there are more layers run the loop again, if not, stop			
			if(files.length>J){
				restartLoop();
				
				}
     }
 
 
 function restartLoop(){
	 J++; //increment J
     batchFiles();//start over
	 
	 }
 
 //setup the Export options for PSD
 function saveOptFunc(){  
		/*
		// Setting IllustratorSaveOptions properties.
		saveOpts = new IllustratorSaveOptions();
		saveOpts.embedLinkedFiles = true;
		saveOpts.fontSubsetThreshold = 0.0
		saveOpts.pdfCompatible = true8
		*/

		// Exporting to Photoshop
		var options = new ExportOptionsPhotoshop();
		options.antiAliasing = true;
	     options.editableText = true;
		options.embedICCProfile = true;
		 options.imageColorSpace = ImageColorSpace.CMYK;
		 options.maximumEditability= true;
		 options.resolution = 1000;
		 options.saveMultipleArtboards = false;
		 options.warnings = true;
		 options.writeLayers = true;
		 
		 return(options);
		 }
	
  /*
End	Script
  */
	 

Photoshop batch to ready images for print

This script will take a group of files, standardize the size and export them at 300ppi for print. It was used to batch CAD images and standardize them for production. Since we were automated image input into the Indesign document, image sizes needed to be standardized so that we could paginate the catalog and get all the images to look the same.

	
/*
*	CADresizer.1.1.0
*	2013 Ashton Watkins 
*	with help from the MultiExporter script by Matthew Ericson
*/

var destFolder, sourceFolder, files, fileType, saveOpts,app,docu;
var J = 0;

// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with PSD files you want', '~' );

// If a valid folder is selected
if ( sourceFolder != null )
{
    files = new Array();
    fileType = '*.psd';
	//fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
    files = sourceFolder.getFiles( fileType);    
    if ( files.length > 0 ){
        //destFolder = Folder.selectDialog( 'Select the folder where you want to save the layers.', '~' );  
        batchFiles();
    } 
 }
    
    
 // Get all files matching the pattern  
 function batchFiles(){   
     
	 if(files.length > J){
     docu  = app.open(files[J]); // returns the document object
		//alert(J);
	  processImages(docu); //sends docment object to the function 
      }
 }//close if source
           
                    
 function processImages(docu){
     var doc = docu;
		 // Create the object to set the options
				
		doc.trim();	
		doc.resizeImage(null, null, 300, ResampleMethod.BICUBIC); 

				// these are our values for the end result width and height (in pixels) of our image
				var fWidth = 1200;
				var fHeight = 1200;

		// do the resizing.  if height > width (portrait-mode) resize based on height.  otherwise, resize based on width
		if (doc.height > doc.width) {
			doc.resizeImage(null,UnitValue(fHeight,"px"),null,ResampleMethod.BICUBIC);
		}
		else {
			doc.resizeImage(UnitValue(fWidth,"px"),null,null,ResampleMethod.BICUBIC);
		}

		// you could call autoContrast and applySharpen on the active layer.
		
		// if we just opened a gif, jpeg, or png, there's only one layer, so it must be the active one


		/* if you want to export for web, use this!
		var options = new ExportOptionsSaveForWeb();
		options.quality = 70;
		options.format = SaveDocumentType.JPEG;
		options.optimized = true;
		var newName = 'web-'+doc.name+'.jpg';
		doc.exportDocument(File(doc.path+'/'+newName),ExportType.SAVEFORWEB,options);
		*/

		doc.save();

		doc.close();			
                      
			if(files.length>J){
				restartLoop();
				
				}
     }
 
 
 function restartLoop(){
	 J++; //increment J
     batchFiles();//start over
	 
	 }

	
  /*
	End	Script
  */

 

Result: increased efficiency

This process streamlined the creation of colorways dramatically and reduced errors. Feel free to use the scripts.

MENU