View Full Version : automation advice
jrcsurvey 05-23-2004, 11:03 PM I have a sequence of images stored as layers in a psd. I would like to save each layer as a separate gif file. Is there anything I can do to automate this process? TIA
| |
look at actions...record the action you want to use, then use batch process on a number of images.
you may run into problems with names of layers though, but i think there is a script somewhere to split layered files into separate files. Have a search on the adobe user to user forums :)
Yeah, Halo is right you will have to use a script to do that, there is one Called "Export Layers To Files" that will create one psd file for each layer, after this is done you might do a batch or use a dropper to convert your files to gif format.
Cheers,
dg
berniebernie
05-26-2004, 02:18 PM
Of course there is !
You must use an Adobe Plug-In called 'scripting' - if you have PS CS it's bundled with the software, if you have PS7 you can download it here (PC) http://www.adobe.com/support/downloads/detail.jsp?ftpID=1536
then read the pdf doc which helps a great deal... Read a few things about scripting; and finally copypaste the following into a .js file (providing you're working with JS and not VisualB or AppleS) in your PS scripts folder...
If all fails; go to http://www.adobeforums.com/cgi-bin/webx?14@184.QZuiczo9yPO.1738844@.ef7ec95 (adobe user to user scripting forums) or PM me
code looks a bit long but it's really simple and has lots of help in it
//***File slightly modified by mlkdesign - mlkdesign at online dot fr*** original author below
// Program Name: Layers to jpg files
//
// Author: Larry B. Ligon
//
// Purpose: This JavaScript will write each normal layer to a separate file in
// jpg format using the layer name as the file name. This includes the
// background.
//
// Requirements: Must have a document open.
//
// Limitations: Does not work for text or shape layer or layers with effects
// or layersets.
// These types of layers have to be rasterized. Does not work with
// linked layers. Has only been tested on Windows machine.
//
var CurrentFolder ;
// a document with layers must already be open.
//Check to make sure that the document has been saved.
//The layers will be save to the same directory that the document is in
if ((documents.length > 0) && (activeDocument.saved))
{
// Tell Photoshop not to display any dialogs.
displayDialogs = DialogModes.NO;
CurrentFolder = activeDocument.path;
// Create a reference to the active document.
var docRef = activeDocument;
// Loop through the layers one at a time. docRef.layers.length contains the number of
// layers including the background.
// Create a counter to count the actual number of layers written to files.
var layerswritten = 0
for (var i = docRef.layers.length-1 ; i >=0 ; i--)
{
// If the layer is not a normal layer, it will be ignored.
if ( docRef.layers[i].kind == LayerKind.NORMAL)
{
// Increment the layers written count.
layerswritten = layerswritten + 1
// Set the active layer to the next layer in the loop.
docRef.activeLayer = docRef.layers[i]
// Copy the contents of the layer to the clipboard.
docRef.layers[i].copy();
// Create a new document with the same dimensions as the original file.
var docRef2 = documents.add(docRef.width,docRef.height,docRef.resolution,
docRef.activeLayer.name);
// Paste the contents of the clipboard to the new file.
docRef2.paste();
// Flatten the file.
//docRef2.flatten;
docRef2.layers[1].remove();
// Create the necessary information for the saveas function.
// Save the layer file to the same directory that the document is in
/* ///////////////////////////////////////////////////////////////////////////
the script below was used to save as jpg - I've changed it to gif
///////////////////////////////////////////////////////////////////////////
// File is saved as Standard baseline with a quality of 10 (Maximum).
// The file name is the name of the layer.
jpgFile = new File(CurrentFolder +"/" + docRef.activeLayer.name);
jpgSaveOptions = new JPEGSaveOptions;
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
// This value can be from 1 to 12.
jpgSaveOptions.quality = 10;
// Save the file as a jpg file.
docRef2.saveAs (jpgFile ,jpgSaveOptions , true, Extension.LOWERCASE);
// Close the new document.
docRef2.close(SaveOptions.DONOTSAVECHANGES);
*/
// set gif save options
saveGifFile = new File(CurrentFolder +"/" + docRef.activeLayer.name);
gifSaveOptions = new GIFSaveOptions();
gifSaveOptions.colors = 256;
gifSaveOptions.transparency = true;
// save as gif
docRef2.saveAs(saveGifFile, gifSaveOptions, true, Extension.LOWERCASE);
docRef2.close(SaveOptions.DONOTSAVECHANGES);
}
}
alert("Wrote " + layerswritten + " layers to files.");
}
else
{
// Gives this message if you don't have a document open in Photoshop.
alert("You must have at least one open document to run this script! \r The document must have been saved to a folder");
}
// Set the objects to nothing to release to the system.
docRef = null
docRef2 = null
CGTalk Moderation
01-18-2006, 08:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2009, Jelsoft Enterprises Ltd.