Export all layers as individual files.
I made a script to export all layers as individual files. The image size was 1280 x 800 pixels at 72 dpi. 4 layers. It worked fine. All layers were exported at the right filesize, the right type of file, and with the given names.
The problem is: what if I want to use the same script on many more layers and higher resolution? This is what happens: all files are exported as blanks. Nothing to see in them.
So: is it possible to make a script that automaticly give names to all the layers, exports all layers there are, and exports all of them at any given size and as as the given file type?
Anyone? Please!?
This is why: I am working on Storybook apps. I make some layers for each page, like background, middleground, foreground, characters, furniture, cars, birds...and so on, each one on a separate layer. Some are going to be animated later as png sprites. All assets are supposed to be separate images from separate layers. Mabe I make 20 pages or 30, it's a lot of job not only painting it all, they all have to have different size. Example: iPad has a different screen size than Android (in fact there are several iOS screen sizes, just as there are different Android screen sizes), Nook got another as well as Kindle. All got different screen ratio aspects too. That is much to do if you have to make it all manually.
I start out making the biggest and crop them down to each aspect ratio and downsize them inside Photoshop using Kutt. But I rather use ArtRage. If there was a script to do this kind of "McDonald" job in ArtRage I would be glad. Instead of being forced to use Photoshop and Kutt.
Script to export separate layers
I'm trying to export separate layers too. So far, I have the script below, and it's working OK. It exports only named layers. The script is so simple, I'm amazed this function is not built in!
If anyone knows how to get the current painting's filename and path as the baseName, or some other way I can replace the InputBox with something more elegant, help would be much appreciated.
Code:
<Events>
int i;
string baseName;
string layerName;
string fileName;
flag overwriteExisting = false;
InputBox( "Base name: $$baseName" );
for ( i = 0; i < LayerCount(); i++ ) {
layerName = LayerName( i );
if ( layerName != "" ) {
fileName = baseName + "_" + layerName + ".png";
if ( FileExists( fileName ) ) {
if ( !overwriteExisting ) {
overwriteExisting = YesNoBox( fileName + " already exists. Overwrite layer files?" );
if ( !overwriteExisting ) {
MessageBox( "Cancelling export" );
exit;
}
}
if ( overwriteExisting ) {
FileDelete( fileName ); // overwrites existing files
}
}
Wait: 0.000s EvType: Command CommandID: ExportLayer Idx: i Channels: NO Path: fileName
}
}
how to get file name & path
Quote:
Originally Posted by
relaxedromance
I'm trying to export separate layers too. So far, I have the script below, and it's working OK. It exports only named layers. The script is so simple, I'm amazed this function is not built in!
If anyone knows how to get the current painting's filename and path as the baseName, or some other way I can replace the InputBox with something more elegant, help would be much appreciated.
Function Name
Function declaration
Description
Example
=======================
Name
string Name()
Return the filename of the file. This is set when the file is opened (either with Open() or with the file dialogs)
s = filDoc.Name()
filDoc.LoadDialog();
if (filDoc.Name() == “fish.txt”)...
-----------------------------------------------------
FullPath
string FullPath()
Returns the full path including the name of the file. This is set when the file is opened (either with Open() or with the file dialogs)
s = filDoc.FullPath();
filDoc.SaveDialog(“Scores.txt”);
if (filDoc.FullPath() == sOld) ...