Thursday, November 1, 2012

Design Calendar Using Scripting in Photoshop CS4

 final image Design Calendar Using Scripting in Photoshop CS4
Creating a graphic calendar by hand is not an easy task. That is why it is best if you can find some way of automating the process. In today’s tutorial we will show you how to generate a full year, custom background calendar using JavaScript. If you’re a bit of a computer programmer, that is great, if not, don’t worry this will be pretty straightforward.



Calendar Using Scripting in Photoshop CS4
Step 1
According to Adobe, a script is a series of commands that tells Photoshop to perform one or more tasks. The first thing you need to do is take a look at Adobe’s JavaScript Reference. You can find it here. This contains all the object properties and methods Photoshop CS4 supports, with examples, and it will give you an idea on what kind of things you can do with scripting in Photoshop. If you are using an older version you can find references here.
Step 2
So let’s get started. The main idea for the project is to create text layers for each month containing the dates, so we will be working mainly with text manipulation. Open ExtendScript Toolkit and create a new JavaScript file (Command+N). This will contain all the commands we are going to give Photoshop. If you don’t want to use ExtendScript Toolkit, you can use any simple text editor.
Step 3
First we have to define some variables for the document attributes and the calendar color scheme. I made my document 1280×800 at 72 pixels/inch resolution, named it “PhotoshopScriptCalendar” and chose 2010 as the year of the calendar we will create.
03 Design Calendar Using Scripting in Photoshop CS4
This is the basic color scheme we are going to use. “NormalColor” is for weekdays and month names. For Sundays I used a different color in order to make them stand out, this is “highlightColor”, and we’ll be using “backColor” as the default calendar background color if we do not select a custom image for that.
03a Design Calendar Using Scripting in Photoshop CS4
Step 4
As I said before, we are mainly going to work with text manipulation, so we must define some variables for the indentation and text that we are going to use repeatedly, like the month headers.
42 Design Calendar Using Scripting in Photoshop CS4
In order to set a different color to the Sundays column, we have to make it a different text layer from the other days. This is why we have two headers: “monthHeader” – Monday to Saturday, and “sundayHeader”. Each of these two variables end with two “r”. These stand for new line characters, the same as pressing the Return key on your keyboard. Next we define the indentation variable. Notice that the first of January is a Friday, so for each day before that we must put an indent instead of numbers. The number of whitespaces of these variables depend on the font you use and the size of it, so it will need a little bit of trail and error before you get it right. Finally, make a list of all the month names.
4a Design Calendar Using Scripting in Photoshop CS4
Step 5
Now that we have every thing we need, we can start creating the .psd document.
52 Design Calendar Using Scripting in Photoshop CS4
As you can see, the code is fairly readable. To our Photoshop application, we add a new document with the specified width, height, resolution, and name we defined earlier, a color mode, and retain its reference in a new variable “doc”. By default all new documents are in RGB, so we could have omitted that parameter, but if you want CMYK for example, you could use “NewDocumentMode.CMYK”. The same with LAB, GRAYSCALE and BITMAP. You can find all of these in the references linked above.
Next we make a new selection and select the entire document, fill it with our background color, and eventually deselect it.
Step 6
Next we need to add a custom background from an existing image. The gradient background from the final result posted above is actually a separate image.
6a Design Calendar Using Scripting in Photoshop CS4
For this we are going to use the openDialog() function. This opens the dialog from “File > Open” and puts in the array “file” the list of selected images. We are going to use only the first selected image which is in the “file” array at position 0. So, first we need to check if any image was selected.
6b Design Calendar Using Scripting in Photoshop CS4
Next, we are going to load the selected image in our application and get a reference to it by calling “app.activeDocument” which returns the currently active document in Photoshop.
6c Design Calendar Using Scripting in Photoshop CS4
Resize the image to our preferred width and height. Again, we make a new selection of the whole document, copy this selection and close the document with the option of not saving the changes.
6d Design Calendar Using Scripting in Photoshop CS4
Finally, in our calendar document, paste the selection. This puts the image as the first layer above the Background layer. Then name it something like “BackgroundImage”.
6e Design Calendar Using Scripting in Photoshop CS4
Notice that if no image was selected from the dialog, none of these commands would have been done.

Hope you enjoy it &learn something new from this tutorial.
Determinebest quality clipping path, clipping path service, low cost clipping path or photoediting&image masking service from Clipping Design. Clipping Design always assurephotoshopmasking, image editing service at quick turnaround time with Guaranteed client satisfaction on top quality SEO service. You can also discover 100% handmade clipping path&clipping path service in reasonable price.
Thank you…
Reference: buildtutorial

No comments:

Post a Comment