Thursday, April 23, 2015

Scripting Animated Tags Tutorial

This tutorial was written by Amber Howard on April 23, 2015. Any resemblances to other tutorials are completely coincidental. Scripting and translating of this tutorial is forbidden. Do not copy and paste this tutorial anywhere else on the internet. Please link back to the main blog instead.

To go with the tutorial I wrote earlier for scripting .JPG and .PNG tags, the tutorial that I am going to do now will describe to you how to script animated tags. I am going to include a lot of information that was found in the previous tutorial, and elaborate on the different processes that are included to make these stunning animated tags. Unlike with the previous tutorial where only two scripts were required, in order to animate tags you will need at least four scripts. A text script, an effect script, an animation script and a merged/effect script. I will go into further details about the differences between these scripts later.

To begin, you will need a copy of PaintShop Pro. I used PSP X7, but any form of the program will do for the majority of this tutorial. If you are going to make the frame scripts on your own, then you will need a version of PSP that will actually allow the script to be made. Unfortunately PSP X to X7 will not support the creation of frame layer scripts. I use PSP9 for this.  

You will, obviously, need a copy of Jasc Animation Shop for this as well. There may be other programs that you can use with this tutorial, but this is the one that I am most familiar with.

Finally, you will need a copy of the TJP-MakeTags main script file by Julie Stenning, which can be downloaded here. This is the most widely used script file for scripting tags, and is very easy to use once the system has been run through a few times and becomes somewhat of a normal process. There are several Yahoo groups out there that can help with scripting as well, please feel free to check them out. The most popular group is Scripting 101, which offers help and tutorials similar to the one that I am writing for you today.

If you have followed my previous tutorial, or already know how to script, please skip the following portion and resume reading this tutorial at the ***GIF SET UP*** marker. Thank you.

Now, before we even begin making a tag, we should set up our folder structure for scripting. For ease of location and not using too many resources on your computer or pushing your PSP program to its limits, it is easier to have most (if not all) of the required folders in one location. The easiest location to remember is in your PSP documents folder.

Depending on which version of the program you are running, it could be listed in a few different ways, but it will always be in your My Documents folder. Newer versions of PSP have the folders we are looking for within the folder tree of My Documents/Corel PaintShop Pro/PSP#/. So, for example if you are running the X7 version of PSP, the tree would look like this: My Documents/Corel PaintShop Pro/17.0/.

Older versions may be contained in My Documents/My PSP Files. Either way you are looking for the folders titled Scripts-Restricted and Scripts-Trusted. These two folders are going to be the life-line of your scripts. The magic will happen almost entirely within these folders, which is why it is easiest to do the pre-tag setup in these locations.

For now, we are going to focus on the Scripts-Trusted folder. When this folder is opened, it should be completely empty if you haven’t scripted before. This is a good thing. Once in this location, you are going to want to create two new folders by either clicking the New Folder button on the top of Windows Explorer, or by right clicking in the blank space and then choosing New/Folder from the menu that appears.

The first folder that you are going to want to create should be titled Scripts. This is where the main script file for each tag that you are going to make will be held. It will keep all of your main scripts together in one easy to locate and easy to edit location, which will help once we actually go to start setting up the main script files.

The second folder that you are going to want to create should be titled Tags. This is where the blank tags that you make will be held. Again, it will keep them all in one easy to locate and edit location which will help for the general ease of scripting once we get to setting up the main script file.

Once you have the two new folders created, you are going to want to create a .txt file within the Scripts-Trusted folder. This file will contain the list of names that you wish to be scripted onto your tag. The easiest way to create one of these files is to right click in the blank space of the folder and then choose New/Text Document from the menu that appears. When it comes to the list of names that you are writing out, there are only a few rules to remember:

1. All names must be located on their own line. If you create a listing of names on the same line, with commas to separate them, the script will read it as one name instead of many names. The basic setup for a name list would look something like this:
Name One
Name Two
Name Three.

2. Spaces are allowed and there are no limits to the number of characters that a name can have. The only limitation comes from the font and font size that you use on the tag. So remember to make sure that your name list is compatible with the font you choose and the space you have to work with. JoBobEllaRulZ! would look great on a tag, but if there isn’t enough space for it to fit, and the font doesn’t support special characters then the results may not be as pretty as you are intending them to be.

3. There are no limits to the number of names that you can put on your list. As long as there is something there, the script will run. One name, fifty names, two hundred names, the length of the list is up to you and your computer. Please be aware that overly long scripts can make your PSP program crash!

The last folder that you will create is a folder to house the completed tags once the main script file has been run. I usually save this file to my Desktop, so that PSP does not get it confused with the other files. It can be placed anywhere on your computer, I do believe, but the Desktop is usually the easiest to locate and remember.

***GIF SET UP***
Unlike the previous tutorial where we only needed three folders in our structure, scripting for animated tags requires four folders. This fourth folder can be placed anywhere on your computer. I usually place mine on the Desktop as well, for ease of locating between programs. This folder can simply be named GIFs, which will be where the main script will save the files to transfer over to Animation Shop. By saving them to a separate folder, there is a lesser chance that you will run into having an issue with file names and overwriting of tags.
***GIF SET UP***

When your file structure setup is complete, we can then move on to the actual scripting process. The above steps will not change no matter how many tags scripts you write. Once you have completed the above, you are done with those steps entirely, unless you wish to add or remove names from your list. The below processes will be the ones that are repeated for each script, so if you need a break, take one.

Back? Okay, good. If you have followed the previous tutorial, or already know how to script, please skip the following portion of the tutorial and move on to the section labeled ***Setting up the Layers***. Thank you.

A good rule of thumb when it comes to scripting is to make sure that your Scripts palette in PSP is always available to you. If you cannot see it on your screen, make sure to go to View-Toolbars-Script and move the newly visible palette to a spot on your window to anchor it there. Mine is set up to look like the image below, and I have circled the Script palette in red. Depending on your version of PSP, it may look different when it comes to the shape/color of the buttons, but nearly all of the Script palettes are the same when it comes to the layout.



First you have the drop down menu that allows you to choose the script file that you wish to run. Ignore this for now. Then, usually, you will have the Run Selected Script button, the Run Multiple Scripts button, the Edit Selected Script button (which I will talk more about later), the Toggle Execution Mode button, the Run Script button, and then the Stop Script, Start Script Recording, Pause Script, Cancel Script Recording, and Save Script Recording Buttons.

Out of this huge list of buttons, the ones to familiarize yourself with are the drop down menu, the Run Selected Script, Edit Selected Script, Start Script Recording, Cancel Script Recording and Save Script Recording buttons. They are the ones that you will use the most.

***Setting Up the Layers***
Once you have completed your tag with its frames and elements and what have you in place and you have cropped away excess canvas, consider how you are going to set up for your animation. Is a tube going to be in front of the animation? Is the animation going to cover everything? Whatever you are going to do, do it. Using Animation Shop, make sure that your tag with the animation is set up just how you want it. At this point, everything should be on the tag except for the name. This includes the copyright information unless the animation would cover the copyrights. This is something that can be added to the tag later if need be.

Once you have your tag in animation shop situated the way that you would like to see it, make sure to highlight all of the layers in your animation. Now, go to File-Save Frames As. This will pop open a save window as exampled below. Change the file name to suit your tag, such as PUTTAGANI1. Make sure that the check box next to ‘Save frames as layers’ is checked and that the file type to save is set to .PSP for Paint Shop Pro Image. This will assure that the file that you save can be opened in PSP again, and will have the proper amount of layers required for the animation. 



If your file is correct, save it as a .pspimage in your Scripts-Trusted/Tags folder. In this you are effectively creating what is called a “blank,” which is a completely finished tag with no name on it. DO NOT share this file with anyone as it is against every company’s TOU to do so!
***Setting Up the Layers***

Now it is time to add your name to your tag. If you have followed the previous tutorial, or already know how to do this step, please skip the following portion and resume reading at the ***Name Effect Layers*** section. Thank you.

The easiest way to go about making sure that you have enough space for all of the names on your list is to use the longest name on your list as the script creator. So, for example, if you have a list of names that include Amber, Kelly, Susan, and JoBobEllaRulZ! on it, then when you type out your name on your tag, you will use JoBobEllaRulZ! since it is the longest. DO NOT convert to raster layer just yet.

Make sure you are happy with the font that you’ve chosen, the color, the placement, everything about the name. Make doubly sure that if there are any letters like ‘y, g, or q’ that hang down that they won’t be hanging off canvas, and that none of your names are too close to any of the edges of the canvas. If you’re done with your name layer, then get ready to create your first required script. In the Script palette, click on the Start Script Recording button. From that point until you save the script, everything that you do in PSP will be recorded, which is why it is a good rule of thumb to make sure everything is settled before you record. What does this specific script record for you? The font you used, the size of the font, the color of the font, and the placement of the font.

Once you have hit the Start Script Recording button, make sure your text tool is active, and edit your name layer. Retype the name out once more, and then apply the text, and convert to raster layer. If you are going to make sure that the name you put on the tag is centered, do so before converting the text to raster by going to Objects – Align – Center Horizontally/Vertically, what have you. Then you can convert it to raster layer. This will make sure that when you run the final script that the centering does not throw off your effects script and make it faulty.

When you are done with that, click the Save Script Recording button. It will pop open a new window in which you choose the name of your script and where it is placed. Make sure that this text script goes into your Scripts-Restricted folder for proper use by the program. Also make sure to name the script properly. For example, if the tag you are creating has the name of PUTTAG1, a good rule of thumb to follow would be to name the text script ‘puttag1text’ so that you can differentiate from the other scripts in your file.

Now, your text script is almost done! Choose the script that you just made from the drop down menu on your Script palette, and then click the Edit Selected Script button. This will pop open another menu that looks like this:



I have circled the button you will want to hit in red. The Text Editor button will pop open Notepad on your computer so that you can edit the script that you just made. In this new file there are only two things that we need to change. Read through the document (it isn’t very far down) to locate the def Do(Environment) : tag within your script. Hit enter once and then place the following text in the new lines that you have created with the exact spacing as in the example picture to follow:
    Results = App.Do(Environment, 'ReturnLayerProperties')
    TagName = Results['General']['Name']


Once you have done that, continue to scroll down your document. You’ll be able to see the font name that you used, the font size, and a bunch of scripting. The part of the document that you are going to be looking for is under the Characters setting. It will be noticed easily as it has the name that you typed out when you created the script. As you can see by the example below, I speak fluent typo-ese. Now, you will want to change this string to the following: 'Characters': TagName,. This will force the script to read the list of names that you wrote out earlier and run those names instead of scripting the characters previously written in the script.


Save and you are done with the first required script! You can close this file now, and return to PSP. It is now time to write out your first effects script. A good rule of thumb would be to actually run yourself through creating the effects first so you know what you are doing, write them down or remember them, erase all of the effects, and THEN write your script so there are no mistakes. Remember, once you hit the Start Script Recording button, PSP will record everything that you do in the program.

Once you are confident in how the effects look, return to a normal raster layer and prepare yourself to write your effect script. Hit Start Script Recording, and then carefully repeat all of the effects that you are going to create. The script will record each plugin and effect that you use, remember the exact settings that you used, and in which order you placed the effect.

***Name Effect Layers***.
When it comes to animated tags, make sure that you do NOT merge your name layer in with the rest of your tag. It should be contained in its own layer entirely so that it can be duplicated and moved around with a frame layer script. If you have duplicated your name layer at all to place different effects on different layers, make sure the final step of your effect script is merging the name layers all into one basic layer. That should leave your layer palette with only the name layer and the tag layer.

Finished with your effect writing? Click the Save Script Recording button, and save once again to the Scripts-Restricted folder. Again, make sure the name that you save as reflects the tag you are making. For example, since we are working on the PUTTAG1 blank, then the script recording would be saved as puttag1effs1. Or something similar to signify that this is the first of the two effect layer scripts required for animated tags.
***Name Effect Layers***

Like before, we have a little bit of editing to do in the created script file. Choose the new script from the drop down menu and then click the Edit Selected Script button. It will either pop up the same menu as before where you click the Text Editor button, or it will pop open a Notepad document for you. Depending on how many effects that are contained in the script, this edit can be easy or it could be time consuming. As you scroll through the document, you will be able to see all of the effects listed out in order of operations. What you are going to look to change is the ExecutionMode part of each effect listing. A freshly created script may have them listed as either Interactive or Default. You want to change all of these to Silent, that way when you run the finalized script, it won’t have fifty-billion pop-ups for every single effect for every single name on every single tag that you make. It will run them silently, with the settings that were already in place at the time of recording. An example of how it should look can be found below:


Once you are done setting all of the effects to Silent, you can save the text document and close it. Now we will begin working on the more difficult aspect of scripting animated tags. If you have followed the tutorial this far, you now have a script for your text and a script for your effects. It is time to make a script for the number of layers that is needed for your animation. These scripts can be called the ‘animation’ script, or as I save them the # ani script. For this tutorial we will be making a basic three-frame animation. Please remember that these scripts cannot be properly created in the X to X7 versions of PSP. PSP9 is by far the best version to use for these scripts, if you have it available. If you don’t have a version available for use (or just want the scripts themselves), I’ve included the animation scripts that I’ve created for 2 frames to 25 frames in a handy dandy zip file that you can download here.

If you downloaded the zip file of scripts, please skip the following portion of the tutorial. Simply unzip the files into your PSP’s Scripts-Restricted folder and then resume reading at the ***Merged/Effect Script*** section.

To begin creating your animation script, open up a blank or white filled 300x300 pixel canvas in PSP9. The space you need isn’t very big at all. Once you have it open, duplicate the background layer so that you have the total amount of frames that your animation has. For the example, we’re making a 3 frame animation, so you would duplicate the background twice for a total of three layers.

Next, grab your text tool and write a single word on the canvas. It doesn’t matter what it is. I usually write TEST out in all capitals. Convert this to raster layer, rename it WORD, and then we’re ready to begin writing the script. Click the Start Script Recording button, and then duplicate the word layer twice. Very carefully arrange the layers so that your layer palette looks like this:
Copy of WORD (2)
Copy of Background (2)
Copy of WORD
Copy of Background
WORD
Background

Once you have that done, carefully merge each set of layers together so that you are merging the Word layer into the Background layer, and are left with the three Background layers when you are finished. Click the Save Recorded Script button, and save the script as ‘3 frame ani’ in the Scripts-Restricted folder. You will have to move it from the PSP9 folder to your versions Scripts-Restricted folder, and then you are done!

***Merged/Effect Script***

With your animated scripts in hand, that leaves one required script left before we can focus on the main script its self. The last script that we will make combines the effect script that was made earlier, and the animation script into one script that can actually be run properly. A good rule of thumb would be to run each of the scripts separately to make sure they work before you try combining the scripts together.

There is a very easy way to test out your animation script. If you did not include your copyright when creating the blank tag, add your copyright information now. Once you are happy with the placement of it, convert the text to raster layer, and then choose the appropriate animation file from the drop down menu in the Script palette. Click the Run Selected Script button with your copyright layer active, and watch the magic happen as the layers are duplicated to the proper number of layers, moved into position on the layer palette and then merged into your blank for you. Then resave your blank with the copyright information added. Easy, right?

To test out your effect script, choose your text script from the drop down menu in the Script palette and then click the Run Selected Script button. This will create a new text layer with the font settings you created the script with and convert it to raster layer for you. Now, you can choose your effect script from the drop down menu and then run it as well to make sure that your effect script works properly. You can delete this layer when you are finished, or you can simply back up a few steps to the creation of the new text layer and use it for the next step.

Once you have a raster text layer on your layer palette, you’re going to click the Start Script Recording button. If you had tested your effect script, it should already be selected in the drop down menu of the Script palette. If it is not, then the first step would be to select the effect script that you created. Then click the Run Selected Script button. Do not save yet. Next, select the proper animation script from the drop down menu in your Script palette, and once again click the Run Selected Script button. This will run the animation script to duplicate, layer, and merge your text layer into your blank. Once it has finished running, you can click the Save Recorded Script button. Save the script in accordance to whichever blank you are using. So, this script would be saved as puttag1effs, to signify that this script is the one that will be used in the main script file.

Congratulations, you now have the three required scripts to make an animated tag with! These include the text script, the effects1 script (your effects script) and the effects script (your merged/effects script,) which were mentioned at the beginning of this tutorial. I will now walk you through how to set up the main script file.

Open the TJP-MakeTags file that you downloaded earlier. Inside of it you will find the main script writings. Scroll through the document until you find the Set Global Variables section of the script. This is the portion of the script that you will always focus on when it comes to writing the main script for each of your tags. Each main file will be different depending on the tag you are working with. So, using the PUTTAG1 example again, let’s set up the final script!

The first thing that you are going to want to change under the Global Variables is the strListofNamesFile setting. At the start it is listed as strListofNamesFile = r''. You are going to modify this string with the address of your names text document which should be saved in your Scripts-Trusted folder. So, open up Windows Explorer once again, and travel through the tree to get the exact address of your file. It would look something similar to this:
C:\Users\YourName\Documents\Corel PaintShop Pro\17.0\Scripts-Trusted\nameslist.txt

So, this is what the string would look like when you have located your text document and input the address:
strListofNamesFile = r'C:\Users\YourName\Documents\Corel PaintShop Pro\17.0\Scripts-Trusted\nameslist.txt'

The next string that you are going to edit is right beneath that, known as the TagTemplate string. This will be the address of the blank that you made earlier, found in your Scripts-Trusted/Tags folder. Once you have the exact address of your blank, input it into the string so that when you have finished it looks similar to this:
strTemplateFileName = r'C:\Users\YourName\Documents\CorelPaintShopPro\17.0\Scripts-Trusted\Tags\PUTTAG1.pspimage'

The next step is completely optional, but I find that it helps a lot when making multiple sets of animated tags. You can set the File Prefix string to add wording to the beginning of your saved file. So, for example, if you wanted to you could fill in that string with ‘1-’ and it will then force the script to name the final tags 1-Amber or whatever the names on your list are. Say you were going to run a second animated script before moving to animation shop, then the second main script that you wrote up would have a ‘2-’ label on it. This will make sure that every time you run a main tag script for an animated tag, it doesn’t try to say that the tags are already made. They’ll have individual labels based on the name of whatever tag you are making. Nifty, right? Right!

The next string that you have to modify is the strTagScriptFile1 file extension. What you will edit this string to include is the text script that you created earlier. For this example, it would look something similar to this:
strTagScriptFile1 = 'puttag1text'

Similarly, the next string that you will edit is the strTagScriptFile2 file extension. What you will edit this string to include is the merged/effect script that you created earlier. ABSOLUTELY make sure that the extension you use in this string is the merged/effect script. If you use the effects script, and not the merged/effect script, then you will end up with a layer that is just the name with the effects that isn’t merged into the animation layers as it should be.  For this example, it would look something similar to this:
strTagScriptFile2 = 'puttag1effs'

Next, you will set the file format that your tag is going to be saved in. For animated tags, you will always set this option to 3 for PSP & (Animation Shop.) It will save the files in a format that is compatible with Animation Shop which will come in handy. Once you have set your file format, then you can move on. File compression depends on your own personal style, and the case font option depends on your name list. I make separate lists with mixed case, lower case and upper case names so I don’t have to mess with that option.

The very last thing that you need to edit in this file is the path directory to where the tags will be saved into. This would be the GIFS folder that you created in your folder structure set up. So, for example, if you placed the folder on your desktop it would look something like this:
strSaveDir = r'C:\Users\YourName\Desktop\GIFS’

Once you have all of your strings completed, save this file into your Scripts-Trusted/Scripts folder. The name that you save it as will depend on the blank you are working on, so for this example, the final script would most likely be saved as PUT Tag1 Ani Script, or something similar.

If you have followed everything up to this point, it is time to see your script in action! Back in PSP, choose the script you just created from the drop down menu in the Script palette. Once you have it selected in the menu, then choose the Run Selected Script button. If everything is set up correctly, then it will pop open a menu with the name of your blank already filled in. Click okay. It will ask you if you want to run the script with the settings chosen, click okay. Again, if everything is set up correctly, then the script will begin to run through the list of names that you created earlier. Once it is finished, it will pop up that it’s finished, and then we move onto the final step.

Make Animation Shop active again, and choose Open from the menu. Navigate to find your GIFS folder on the desktop, and inside should be all of the files that your script just created. Select and open them. You can now view your animation to make sure it is correct, and that everything is supposed to be where it is supposed to be. From there you can fiddle with the frame settings to fit the animation you used, and then save the files as normally. Ta-da! You have created your first scripted animation tag. Congratulations!

If your script did not run correctly, or it threw up an error of some sorts, go back to double check that there were no typos in your editing, and that everything is labeled as it should be. If you get to the final step and see that the name wasn’t properly merged into the frames like it was supposed to be, go back and make sure that you used the proper script in your main file. Feel free to e-mail me at anoblivioncreation@gmail.com or ping me on Facebook if you have any questions!


2 comments:

  1. Thx hun, got it bookmarked and try this out asap!! <3

    ReplyDelete
  2. Thank you -- Never scripted before yet this gives me hope!!!!

    ReplyDelete