PDA

View Full Version : Export all layers as individual files.



Henry Stahle
02-19-2014, 01:04 AM
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.

DaveRage
02-21-2014, 11:14 AM
Could you zip the script up and send it to me at [email protected] so I can take a look?

DaveRage
02-24-2014, 03:47 PM
After looking the file, this script was created via recording in ArtRage. Scripts recorded in ArtRage will play back by creating a new painting of the original specified size or a new size specified by the user when the script is played back. ( the 'original size' option you see when you start playback )

Here's what to do:

Open your script file in notepad if you're on Windows or textedit if you're on a Mac.

Locate this block:

<Header>
// === Project data
Painting Name: "Untitled"
Painting Width: 1280
Painting Height: 800
Painting DPI: 72
Mask Edge Map Width: 1920
Mask Edge Map Height: 1200
// === Author data
Author Name: "HS"
Script Name: "Export Layers"
Comment: "Export layers as individual png files"
Script Type: ""
Script Feature Flags: 0x000000034
</Header>

Either set Script Feature Flags to 0x000000000 or delete this line entirely

Save the script with a new filename. You can now use it to export the first four layers from files of any size. This script will only export four layers as this is what was recorded. You can add additional layers by editing the <Events> section

e.g.

Wait: 5.132s EvType: Command CommandID: ExportLayer Idx: 3 Channels: NO Path: "C:\Users\xxxxx\Desktop\Layer 4.png"

This exports layer 4 to the specified path. You could add another line below, changing the Idx value to 4 ( layers start at 0 so this would be layer 5 ) and export it as Layer 5.png and so on.

You could in theory program a script to export all the layers of the painting by getting the number of layers, then doing a loop ( see the document below ). Script programming isn't something I can provide support for however. Alternatively you could add a number of further layer export entries then just press the stop button during playback when you have exported the last layer.

You can find more information on advanced script programming here:

http://www.artrage.com/files/artrage_advancedscriptingguide.pdf

I hope this helps!

Henry Stahle
02-24-2014, 10:07 PM
I think I get it, although there is an issue with me and scripting and coding. I will try to get it right. Thank you very much for your help.

rmartinr
06-07-2016, 04:13 PM
Hi! That's an amazing capability! Where are commands like ExportLayer documented? How would one figure those out?

HannahRage
06-07-2016, 04:16 PM
Hi! That's an amazing capability! Where are commands like ExportLayer documented? How would one figure those out?

The commands aren't documented publically anywhere, the best and quickest way to start a script and figure out the commands you want is to create a practice one (i.e. do the things you want in ArtRage and record it), then edit the document it gives you.

relaxedromance
04-13-2017, 11:45 PM
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.



<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

}

}

runningbull
08-21-2021, 06:55 AM
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) ...