Sunday, July 12, 2009

Photoshop Brush Tutorial

In this tutorial I’m going to show you how to create an effect like this. Very simple and short. Some of you will recognize the tutorial. You’re right, it’s already at deviantArt, but I still get so much requests, so .. here it comes :)

Step 1

Start with a new file and choose any size you want (I took 560×226). Paint the layer black and create a new layer (!).

Step 2

Get some brushes from here and install them. Now set white as foregroundcolor, choose one (or more) of the brushes and add them by clicking on the image.

Step 3

Duplicate the layer, use gaussian blur (~5px) and set the oppacity of the layer to ~40%.

Step 4

Create a new layer and use the big 300px brush with 2 colors you want to paint over the picture.Take care: The 2 colors have to be in the same layer!

Step 5

Set the layer on color and create a new layer (and press D! - black and white as colors). Use render -> clouds and then the gaussian blur (about 10px). Set the layer on vivid light. Your result should look like this.

Optional Step

If the glow isn’t strong enough: Take the 100px pencilbrush, set white as color and set the oppacity of the pencilbrush to ~20%. Now you can add by simple clicking very nice highlights (same works with black as color).

Where to download photoshop brush and install them

This photoshop tutorial video will tell you where to download photoshop brush and how to install them to your photoshop brush palette. Photoshop brush is a common use to create an effect in photoshop. There are many good website that provide free photoshop brush that you can use in your design. You can download the brush that will suite your design. This photoshop video tutorial will tell you where you can download free photoshop brush dan how to install them and use it in your design. This video byinsidegeek

website that provide free photoshop brush:
1. www.brusheezy.com/brushes
2. www.photoshopsupport.com/tools/brushes.html
3. tutorialblog.org/free-photoshop-brushes
4. www.easyelements.com/free-photoshop-brushes.html
5. www.brushking.eu/


Our Latest Totorial



Photography Tips From A Pro On Shooting In Low Light

If you are shooting wide open, which is at the camera’s largest aperture, your depth of field will be correspondingly shallow. That means your focus is going to be even more critical than otherwise. Pick a point that needs to be sharp and really pay attention to keeping that point sharp. Generally, if you are shooting people, the most important thing to keep sharp is the eyes. When I am shooting people I focus on the eyes, shoot, re-focus and shoot again …and then do it all over again. I can’t tell you how much I hate to be editing and find that I have a potentially great shot, but out of focus eyes ruin the picture. I have found that if I am worried about an image not being sharp, I am usually right. Pixels are cheap…shoot enough to make sure you have your shot!

77335_nature_9

Shooting for stock, know your equipment, know your agency

If you are shooting with a stock agency in mind it is good to know just how high you can push your ISO before you reach the point where the agency is going to reject the image. That means you have to know both your own equipment and the standards of the agency. I was once shooting from the interior of a jeep on a mountain road in China. The scene, road-building equipment clearing a landslide, was lit by the headlights of the cars waiting for the road to be cleared. I shot the scene, hand held, but braced against the head-rest, at an ISO of 1600 with a Canon 1ds. Man did I work on that image in post (processing the digital files)! They accepted it too. With the newer cameras I have no qualms about shooting at 400, I am comfortable shooting at 800 and don’t think 1600 would really be such a stretch. But don’t take my word for it… do some testing!

Exposure and more

RAW (the file format native to the camera) has been talked to death, but keep in mind that it is more akin to negative film than transparency film and I personally find that I can safely get another stop to a stop-and-a-half in post-shoot processing. Shoot RAW, not jpeg! As far as exposure, keep your histogram as far to the right as possible without clipping (going off the edge). If you loose your highlights (which are on the right hand side of the histogram) you probably can’t get them back. I guess in that way a digital file is like transparency film.

waves on long exposure

I am not a big user of on-camera flash, but it can be a real life-saver. I suggest a good starting point is to set your flash to under expose by two-thirds of a stop. That can help bring out details without overpowering the image…and looking like you used on-camera flash! If you do use on-camera flash it is generally a good idea to bounce it or at least put some sort of diffuser over it.

Use movement to your advantage

Another thing to keep in mind is that a little movement in your image isn’t necessarily an image killer. Sometimes you can make it work to your advantage. A year ago I was shooting in the train station in Mumbai, India. The station is indoors and while it wasn’t exactly gloomy, it still qualifies as low light. I put the camera over my head as high as I could hold it and fired off a half-dozen frames at an eighth of a second. I only shot six frames because at that point a machine gun carrying police officer politely but firmly informed me that photography in the train station was forbidden. That image, in which everything has movement, even the lamp posts, has already sold a number of times as a stock picture with Getty Images (1377). Sometimes movement can make an image more dynamic and help it convey a mood or message.

Make Taped Photo Effect

oday's I am going to show you how to add a simple taped down effect to your photos.

Step 1: Open up a photo on which you want to add this taped down effect. Place it to document which have you created in first step.

Open up a Photo and Place it to a Document

Step 2: So, we are going to rotate this picture a bit. Go to Edit> Free Transform (shortcut key of 'Free Transfort Ctrl+T').

Rotate the Picture

Step 3: We will make a tape. First create a new layer. Then by using Rectangular Marquee Tool make a selection. Fill it with white and press Ctrl+D for deselect the selection. Now go to Layer> Layer Style> Stroke and apply the following setting:

Stroke Setting

Now change the Fill of the layer to '40%'. After this your tape looks like:

Stroke Setting

Step 3: By using Lasso Tool make a selection like a picture shown below and press Delete. This will add cut off effect to our tape.

Tape Cut Effect

Now go to Select> Deselect (Shortcut key Ctrl+D). Here's your result:

Tape Cut Effect

Repeat this process for the other side.

Tape Cut Effect Both Sides

Step 4: Duplicate this layer by three times by press Ctrl+J and place each layer on different corner. Rotate them Edit> Free Transform (Ctrl+T) so that they fit into your photo.

Here's the final result!

Taped Photo Effect

How to install Brushes in Adobe Photoshop CS3

If you've downloaded the .abr file and don't know what to do next, read this tutorial.

  1. Put the .abr file you've downloaded into the folder/Users/{username}/Library/Application Support/Adobe/Adobe Photoshop CS3/Presets/Brushes (on mac OS X) or C:\Program Files\Adobe\Photoshop\Presets\Brushes (on Windows) .
  2. Then open your Adobe Photoshop, active brush tool, go to option palette and click on to open the brush preset picker.

install brushes tutorial screenshot

Then click on little triangel in the right upper corner.

install brushes tutorial screenshot

Next on the list you choose 'Load Brushes'

install brushes tutorial screenshot

In the dialog box choose the .abr file you want to load and your new brushes appear in the Brush palette and are just ready to use.

Tuesday, July 7, 2009

Step 5
Now we can really just use our imagination and simply duplicate this “lines” layer a few times, rotate and resize each duplicated layer until the outcome is desirable:
Here is my effect so far:


Merge the duplicate layer together.
We can also add a bit of glowing effect to the spectrum lines. To do this, simple duplicate the merged layer and apply the following Gaussian Blur settings: (Filter > Blur > Gaussian Blur)


Change the blending mode the duplicated layer to “Linear light” and you will have the following effect:


To add some final touches, remember we created a new brush preset in Step 1? We can use it to add some nice dots on the abstract line.
Create a new layer called “dots” on top of all other layers, grab that brush preset and simply paint over the lines:


Then Change the layer blending mode to “Overlay” and you will have the following effect:


Duplicate this “dots” layer and change the blending mode of the duplicated layer back to “normal”, then reduce its opacity to 15% and erase some excessive parts.

You will have the following final effect:


Ok that’s it for this tutorial! Of course you can further enhance this image by adding some more effect, textures and filters.

Here is my final version for this tutorial: (Added a bit of cloudy effect and sharpen the image )


Hope you enjoy this tutorial and find it useful, drop me a comment if you have any question, I will try my best to help you out.
Cheers and have a nice day!





Create

Then duplicate this layer 4 times and merge the duplicated layer together, you will have the following effect:


Rename this layer as “lines” after the merge.
Step 4
Again we duplicate the “lines” layers 3 times, and you will see the colour of the the spectrum become clearer:


Then we merge those duplicated layer together, then use the Free Transform tool to resize it into the following:


Then we can use the Warp Tool (Ctrl + T and right-click select “Warp”), transform it into the following shape:



And here is the effect after warping:







Monday, July 6, 2009

Create Simple, Yet Elegant Abstract Spectrum Lines in Photoshop Part 3

Then choose the option “brush” and tick the “Simulate Pressure”:


And you will have the following effect:

Step 3
Still on this “lines” layer, go to Filter > Blur > Motion Blur and apply the following settings:


Then hit Ctrl + F and apply the motion blur filter again, and you will have the following effect:


Apply the following Gradient Overlay blending option to this layer:




Create Simple, Yet Elegant Abstract Spectrum Lines in Photoshop Part 2

Make sure you also select the Airbrush and Smoothing option.
After finishing making this brush, let’s save it as a new brush preset so that we can use it in the future too. To do this, left-click the down tri-angle on the top right and click “new brush preset”:

And Enter the following into the window popup:

Then you will see the brush preset appear in the brush selection window:


Step 2
Create a new layer call “lines”, grab the Pen Tool and draw the following working path:



Hint: hold down Shift key and drag your mouse upwards approximately 45 degree for both archor points.

Then right-click and select the option “Stroke Path”:






Create Simple, Yet Elegant Abstract Spectrum Lines in Photoshop part 1

In this tutorial, I will show you the method I use to design a simple, yet elegant abstract spectrum lines in Photoshop. You will see how easy it is to achieve this nice effect and you can use it a wide range of occasions including perhaps site header backgrounds, logos, or add extra flavor to your photo manipulations.
This tutorial is suitable for beginners and I included the ways of creating new brush presets and also the use of Pen Tool. You will ample opportunities to practive layer blending, filters and Free Transform Tools. Have a try!
Here is a preview of the final effect: (click to enlarge)



Ok let’s get started!

Step 1
Create a new document with black background, for size I chose 980px * 400px however you can change this according to your own preference. Use 72 pixel/inch for resolution since we’re creating an image used for website.
Now let’s make a new brush preset. To do this, firstly select the brush tool with the following brush:






Then apply the following brush dynamics to it:
Shape Dynamics




Scattering




Other Dynamics





Tuesday, June 9, 2009

SSpecial Effects - Special Effects last steps

Step 9
Now we'll add a dramatic glow to the tiles. Before we begin, zoom in to 100% so that you can see the individual tiles. Open the Filter> Blur menu and select Gaussian Blur. In the Gaussian Blur filter tool, adjust the radius so that the tiles create a soft glow effect.
Step 10
We're done! But here's one more step in case you feel that the outline is too thin and you would like to thicken it. Open the Filter> Other menu and select Maximum. Adjust the radius slightly to increase the size of the outline. Click OK when done.
Final Results
Original Photo
Disco Tiles Photoshop Tutorial
window.google_render_ad();

Special Effects - Special Effects step 5 - 8

Step 5
We're done creating the tile pattern, so we'll work on creating the outline now. Duplicate the layer by pressing Ctrl+J or opening the Layer menu and selecting Duplicate. Next, change the blending mode of the new layer to Screen.
Step 6
Apply a find edges filter by opening the Filter> Stylize menu and selecting Find Edges. This filter draws an outline of the edges.
Step 7
Press Ctrl+I or open the Image> Adjustments menu and select Invert. The outline should be blended into the photo.
Step 8
The tiles and outline effect is now complete. But the effect looks flat and boring. In the next steps, we'll enhance it using a new layer that will add depth and a glow effect to the tiles. First, press Shift+Ctrl+E or open the Layer menu and select Merge Visible. This will create a duplicate of the image as a single layer. Change the blending mode to Overlay. By adding a duplicate of the image with an Overlay blending mode, we can increase the contrast which will enhance the appearance of depth in the tiles.
window.google_render_ad();

Special Effects - Special Effects step 1 -4

Page 1 of 3
Tired of old boring prints? Try out this fun photo effect on your photos that you can print out to impress your friends. From a distance, it will look like a normal photo but view the printed image up close and you'll see an abstract mosaic pattern that resembles a disco floor. This Photoshop effect is also great for enlarging low resolution photos into poster-size prints.
Preview of Final Results

http://photoshoptutorials.ws/images/stories/Photoshop%20Tutorials/Special%20Effects/Disco%

Disco Tiles Photoshop Tutorial
Step 1
Run Photoshop and open the photo you would like to add this effect to into Photoshop.

http://photoshoptutorials.ws/images/stories/Photoshop%20Tutorials/Special%20Effects/Disco%20Tiles/open.jpg

Step 2
Next, we need to resize the image to the final output size that we would like to print at. Enter the width and height for the document size and specify the resolution. You can set the resampling method to Nearest Neighbor to speed up this process.

http://photoshoptutorials.ws/images/stories/Photoshop%20Tutorials/Special%20Effects/Disco%20Tiles/resize.jpg

Step 3
Before we continue, zoom out so that you can see the whole image. Now open the Filter> Pixelate menu and select Mosaic. In the Mosaic filter tool, adjust the cell size to the largest possible that will retain important details. If you are working on a portrait, you can simply look at the eyes as you adjust the cell size.

http://photoshoptutorials.ws/images/stories/Photoshop%20Tutorials/Special%20Effects/Disco%20Tiles/pixelate.jpg

Step 4
The image is pixelated, but it doesn't look very special. So before we continue, we'll curve the edges for a more contemporary effect. To do this, open the Filter> Noise menu and select Median. Adjust the radius of the filter until you get the rounded corners that you like.

http://photoshoptutorials.ws/images/stories/Photoshop%20Tutorials/Special%20Effects/Disco%20Tiles/median.jpg

Manipulate an Image with Scripting 5

select the image layer, rotate it then merge them.
Final Script:preferences.rulerUnits = Units.PIXELS;
displayDialogs = DialogModes.NO
open(File(openDialog()));
var docRef_1 = activeDocument;
docRef_1.backgroundLayer.duplicate();
var white = new SolidColor();
white.rgb["hexValue"] = "ffffff"
var black = new SolidColor();
black.rgb["hexValue"] = "000000"
foregroundColor = black;
backgroundColor = white;
docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
docRef_1.layers[0].duplicate();
docRef_1.activeLayer = docRef_1.layers[0];
docRef_1.activeLayer.applyAverage();
for (RLevel = 0; RLevel <= 255; RLevel ++) {
if (docRef_1.channels["Red"].histogram[RLevel]) {
break;
}
}
for (GLevel = 0; GLevel <= 255; GLevel ++) {
if (docRef_1.channels["Green"].histogram[GLevel]) {
break;
}
}
for (BLevel = 0; BLevel <= 255; BLevel ++) {
if (docRef_1.channels["Blue"].histogram[BLevel]) {
break;
}
}
var R = 0;
var G = 0;
var B = 0;
if (RLevel > GLevel && RLevel > BLevel) {
R = 255;
}
if (GLevel > BLevel && GLevel > RLevel) {
G = 255;
}
if (BLevel > RLevel && BLevel > GLevel) {
B = 255;
}
var color = new SolidColor();
color.rgb.red = R;
color.rgb.green = G;
color.rgb.blue = B;
docRef_1.selection.selectAll();
docRef_1.selection.fill(color);
docRef_1.selection.deselect();
docRef_1.activeLayer.invert();
docRef_1.activeLayer.blendMode = BlendMode.COLORBLEND;
docRef_1.activeLayer.opacity = 50;
docRef_1.activeLayer.merge();
var width = docRef_1.width;
var height = docRef_1.height;
if (width <= height) {
var borderSize = Math.round(width * 0.15);
}
else {
var borderSize = Math.round(height * 0.15);
}

docRef_1.resizeCanvas(width + borderSize, height + borderSize);
docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
docRef_1.layers[0].merge();
docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(black);
docRef_1.selection.deselect();
var width = docRef_1.width;
var height = docRef_1.height;
var newSize = Math.round(Math.sqrt(width * width + height * height)) + borderSize;
docRef_1.resizeCanvas(newSize, newSize);
docRef_1.activeLayer.applyGaussianBlur(borderSize / 3);
docRef_1.activeLayer.opacity = 50;
var angle = Math.round(Math.random() * 40) - 20;
docRef_1.activeLayer.rotate(angle, AnchorPosition.MIDDLECENTER);
docRef_1.activeLayer = docRef_1.layers[0];
docRef_1.activeLayer.rotate(angle, AnchorPosition.MIDDLECENTER);
docRef_1.activeLayer.merge();

Manipulate an Image with Scripting 4

Step 11:
Now we want to invert the color of this layer then change its blending mode to color and its opacity to 50%. The code for doing this is.docRef_1.activeLayer.invert();
docRef_1.activeLayer.blendMode = BlendMode.COLORBLEND;
docRef_1.activeLayer.opacity = 50;
docRef_1.activeLayer.merge();
Each command here explains itself fairly well, this process would be done in Photoshop by hitting Ctrl+I then changing the blending mode and opacity manually in the layers panel then hitting Ctrl+E.
Step 12:
Now we want to add the border, the way I did this was to have this script enlarge the canvas then create a new layer and do a select all and fill this layer white. Before we do this we need to have the script calculate the size of the border depending on the size of the image. After a bit of trial and error I found a good border thickness to be 7.5% of the smaller dimension; either the height or the width. To implement this we first need to find which is smaller the width or the height then to make the border size equal to 7.5% of this. Lastly we have to double this thickness then add it to the width and the height to get the new canvas size. To simplify this slightly I just took 15% rather than 7.5% then I didn't need to double it before I added it on. The code for this stage is:var width = docRef_1.width;
var height = docRef_1.height;
if (width <= height) {
var borderSize = Math.round(width * 0.15);
}
else {
var borderSize = Math.round(height * 0.15);
}
docRef_1.resizeCanvas(width + borderSize, height + borderSize);
Okay, the first two lines are easy; we are setting a variable for the width which is equal to the document width and a variable for the height which is equal to the document height.
Then we have an 'if' statement which says if the width is smaller or equal to the height then execute the command in the curly brackets. The first part of this command looks familiar; just creating a variable, the second part uses a Math function called round, what this does is to round whatever is in the brackets to the closest integer or whole number. We need this because some of the time 15% of the width will be a decimal number.
After this 'if' statement we have an 'else' statement which means if the width is larger than the height then it will execute the command contained within these curly brackets; which is similar to the other command.
The last line resizes the canvas to a width and height equal to borderSize added to the width and height. Note that the 1px border around these images is just added in because the background is also white.
Step 13:
Now if you tested the script you might think it looks fine however the background layer will resize to fit any size of canvas so we need to have the script create a new layer with the border in it then merge this layer and the image layer. The code for this is:docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
docRef_1.layers[0].merge();
The only part of this code that we haven't seen before is the move command which we are using on the active layer which will be the one we just created. The first part inside the brackets is the reference layer which we have defined as the background layer, the second part tells Photoshop to move the active layer to before the reference layer using ElementPlacement.PLACEBEFORE.
Step 14:
Now we are going to add what will become the shadow, at the moment this will just be a layer directly before the background layer filled with black. Here is the code:docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(black);
docRef_1.selection.deselect();
This code is nearly exactly the same as the code in the last step except that this is filled black and we don’t merge it yet. If you test it shouldn't look any different from what it did in the last step.
Step 15:
Okay now we want the script to resize the canvas so it can fit the image at any angle; this requires good old bit of Pythagoras. The code for this is:var width = docRef_1.width;
var height = docRef_1.height;
var newSize = Math.round(Math.sqrt(width * width + height * height)) + borderSize;
docRef_1.resizeCanvas(newSize, newSize);
The first two lines create new variables for the width and height. The next line create a variable for the new size of the document, the Math.sqrt function in this takes the square root of the number in the brackets and we add the borderSize just to account for the shadow we will create. The last line is resizing the canvas.
Step 16:
Now to create the shadow, we want the script to add a gaussian blur to the black layer we created earlier. I found that the value for the gaussian blur should be a third of the borderSize and the opacity, 50%. Here's the code for this part:docRef_1.activeLayer.applyGaussianBlur(borderSize / 3);
docRef_1.activeLayer.opacity = 50;
The first line is in the same for as the average blur which we made in step 5.
window.google_render_ad();
<<> - Next >>
More tutorials by Ross Aitken
Design a Web Template using the “960 Grid System” (29 December 2008)
How to Create an Abstract Photo Manipulation (10 September 2008)
How to Create a Movie Quality DVD Cover (10 November 2008)
Decorating Text (09 June 2008)
Retro Text (16 July 2008)
Active Writers
Denny Tang is the founder of Photoshop Tutorials and specializes in photo editing with Adobe Photoshop.
Oliver Cereto is a graphic designer and photographer from Málaga, Spain. View more of Oliver's work at olivercereto.com.
Ross Aitken is currently studying design at Glasgow, UK. You can find more tutorials by Ross at PSD Learning.
Become a writer
if (!window.netshel_ord) { netshel_ord=Math.random()*10000000000000000;
}
if (!window.netshel_tile) { netshel_tile=1; }
document.write('');
netshel_tile++;
document.write("");document.getElementById("img1").src="http://beacon.scorecardresearch.com/scripts/beacon.dll?C1=8&C2=2102&C3=303&C4=504310&C5=&C6=&C7=" + escape(window.location.href) + "&C8=" + escape(document.title) + "&C9=" + escape(document.referrer) + "&C10=" + escape(screen.width+'x'+screen.height) + "&C15=&C16=&rn=" + Math.floor(Math.random()*99999999);

Manipulate an Image with Scripting 4

Step 11:
Now we want to invert the color of this layer then change its blending mode to color and its opacity to 50%. The code for doing this is.docRef_1.activeLayer.invert();
docRef_1.activeLayer.blendMode = BlendMode.COLORBLEND;
docRef_1.activeLayer.opacity = 50;
docRef_1.activeLayer.merge();
Each command here explains itself fairly well, this process would be done in Photoshop by hitting Ctrl+I then changing the blending mode and opacity manually in the layers panel then hitting Ctrl+E.
Step 12:
Now we want to add the border, the way I did this was to have this script enlarge the canvas then create a new layer and do a select all and fill this layer white. Before we do this we need to have the script calculate the size of the border depending on the size of the image. After a bit of trial and error I found a good border thickness to be 7.5% of the smaller dimension; either the height or the width. To implement this we first need to find which is smaller the width or the height then to make the border size equal to 7.5% of this. Lastly we have to double this thickness then add it to the width and the height to get the new canvas size. To simplify this slightly I just took 15% rather than 7.5% then I didn't need to double it before I added it on. The code for this stage is:var width = docRef_1.width;
var height = docRef_1.height;
if (width <= height) {
var borderSize = Math.round(width * 0.15);
}
else {
var borderSize = Math.round(height * 0.15);
}
docRef_1.resizeCanvas(width + borderSize, height + borderSize);
Okay, the first two lines are easy; we are setting a variable for the width which is equal to the document width and a variable for the height which is equal to the document height.
Then we have an 'if' statement which says if the width is smaller or equal to the height then execute the command in the curly brackets. The first part of this command looks familiar; just creating a variable, the second part uses a Math function called round, what this does is to round whatever is in the brackets to the closest integer or whole number. We need this because some of the time 15% of the width will be a decimal number.
After this 'if' statement we have an 'else' statement which means if the width is larger than the height then it will execute the command contained within these curly brackets; which is similar to the other command.
The last line resizes the canvas to a width and height equal to borderSize added to the width and height. Note that the 1px border around these images is just added in because the background is also white.
Step 13:
Now if you tested the script you might think it looks fine however the background layer will resize to fit any size of canvas so we need to have the script create a new layer with the border in it then merge this layer and the image layer. The code for this is:docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
docRef_1.layers[0].merge();
The only part of this code that we haven't seen before is the move command which we are using on the active layer which will be the one we just created. The first part inside the brackets is the reference layer which we have defined as the background layer, the second part tells Photoshop to move the active layer to before the reference layer using ElementPlacement.PLACEBEFORE.
Step 14:
Now we are going to add what will become the shadow, at the moment this will just be a layer directly before the background layer filled with black. Here is the code:docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(black);
docRef_1.selection.deselect();
This code is nearly exactly the same as the code in the last step except that this is filled black and we don’t merge it yet. If you test it shouldn't look any different from what it did in the last step.
Step 15:
Okay now we want the script to resize the canvas so it can fit the image at any angle; this requires good old bit of Pythagoras. The code for this is:var width = docRef_1.width;
var height = docRef_1.height;
var newSize = Math.round(Math.sqrt(width * width + height * height)) + borderSize;
docRef_1.resizeCanvas(newSize, newSize);
The first two lines create new variables for the width and height. The next line create a variable for the new size of the document, the Math.sqrt function in this takes the square root of the number in the brackets and we add the borderSize just to account for the shadow we will create. The last line is resizing the canvas.
Step 16:
Now to create the shadow, we want the script to add a gaussian blur to the black layer we created earlier. I found that the value for the gaussian blur should be a third of the borderSize and the opacity, 50%. Here's the code for this part:docRef_1.activeLayer.applyGaussianBlur(borderSize / 3);
docRef_1.activeLayer.opacity = 50;
The first line is in the same for as the average blur which we made in step 5.
window.google_render_ad();
<<> - Next >>
More tutorials by Ross Aitken
Design a Web Template using the “960 Grid System” (29 December 2008)
How to Create an Abstract Photo Manipulation (10 September 2008)
How to Create a Movie Quality DVD Cover (10 November 2008)
Decorating Text (09 June 2008)
Retro Text (16 July 2008)
Active Writers
Denny Tang is the founder of Photoshop Tutorials and specializes in photo editing with Adobe Photoshop.
Oliver Cereto is a graphic designer and photographer from Málaga, Spain. View more of Oliver's work at olivercereto.com.
Ross Aitken is currently studying design at Glasgow, UK. You can find more tutorials by Ross at PSD Learning.
Become a writer
if (!window.netshel_ord) { netshel_ord=Math.random()*10000000000000000;
}
if (!window.netshel_tile) { netshel_tile=1; }
document.write('');
netshel_tile++;
document.write("");document.getElementById("img1").src="http://beacon.scorecardresearch.com/scripts/beacon.dll?C1=8&C2=2102&C3=303&C4=504310&C5=&C6=&C7=" + escape(window.location.href) + "&C8=" + escape(document.title) + "&C9=" + escape(document.referrer) + "&C10=" + escape(screen.width+'x'+screen.height) + "&C15=&C16=&rn=" + Math.floor(Math.random()*99999999);

Manipulate an Image with Scripting 4

Step 11:
Now we want to invert the color of this layer then change its blending mode to color and its opacity to 50%. The code for doing this is.docRef_1.activeLayer.invert();
docRef_1.activeLayer.blendMode = BlendMode.COLORBLEND;
docRef_1.activeLayer.opacity = 50;
docRef_1.activeLayer.merge();
Each command here explains itself fairly well, this process would be done in Photoshop by hitting Ctrl+I then changing the blending mode and opacity manually in the layers panel then hitting Ctrl+E.
Step 12:
Now we want to add the border, the way I did this was to have this script enlarge the canvas then create a new layer and do a select all and fill this layer white. Before we do this we need to have the script calculate the size of the border depending on the size of the image. After a bit of trial and error I found a good border thickness to be 7.5% of the smaller dimension; either the height or the width. To implement this we first need to find which is smaller the width or the height then to make the border size equal to 7.5% of this. Lastly we have to double this thickness then add it to the width and the height to get the new canvas size. To simplify this slightly I just took 15% rather than 7.5% then I didn't need to double it before I added it on. The code for this stage is:var width = docRef_1.width;
var height = docRef_1.height;
if (width <= height) {
var borderSize = Math.round(width * 0.15);
}
else {
var borderSize = Math.round(height * 0.15);
}
docRef_1.resizeCanvas(width + borderSize, height + borderSize);
Okay, the first two lines are easy; we are setting a variable for the width which is equal to the document width and a variable for the height which is equal to the document height.
Then we have an 'if' statement which says if the width is smaller or equal to the height then execute the command in the curly brackets. The first part of this command looks familiar; just creating a variable, the second part uses a Math function called round, what this does is to round whatever is in the brackets to the closest integer or whole number. We need this because some of the time 15% of the width will be a decimal number.
After this 'if' statement we have an 'else' statement which means if the width is larger than the height then it will execute the command contained within these curly brackets; which is similar to the other command.
The last line resizes the canvas to a width and height equal to borderSize added to the width and height. Note that the 1px border around these images is just added in because the background is also white.
Step 13:
Now if you tested the script you might think it looks fine however the background layer will resize to fit any size of canvas so we need to have the script create a new layer with the border in it then merge this layer and the image layer. The code for this is:docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
docRef_1.layers[0].merge();
The only part of this code that we haven't seen before is the move command which we are using on the active layer which will be the one we just created. The first part inside the brackets is the reference layer which we have defined as the background layer, the second part tells Photoshop to move the active layer to before the reference layer using ElementPlacement.PLACEBEFORE.
Step 14:
Now we are going to add what will become the shadow, at the moment this will just be a layer directly before the background layer filled with black. Here is the code:docRef_1.artLayers.add();
docRef_1.activeLayer.move(docRef_1.backgroundLayer, ElementPlacement.PLACEBEFORE);
docRef_1.selection.selectAll();
docRef_1.selection.fill(black);
docRef_1.selection.deselect();
This code is nearly exactly the same as the code in the last step except that this is filled black and we don’t merge it yet. If you test it shouldn't look any different from what it did in the last step.
Step 15:
Okay now we want the script to resize the canvas so it can fit the image at any angle; this requires good old bit of Pythagoras. The code for this is:var width = docRef_1.width;
var height = docRef_1.height;
var newSize = Math.round(Math.sqrt(width * width + height * height)) + borderSize;
docRef_1.resizeCanvas(newSize, newSize);
The first two lines create new variables for the width and height. The next line create a variable for the new size of the document, the Math.sqrt function in this takes the square root of the number in the brackets and we add the borderSize just to account for the shadow we will create. The last line is resizing the canvas.
Step 16:
Now to create the shadow, we want the script to add a gaussian blur to the black layer we created earlier. I found that the value for the gaussian blur should be a third of the borderSize and the opacity, 50%. Here's the code for this part:docRef_1.activeLayer.applyGaussianBlur(borderSize / 3);
docRef_1.activeLayer.opacity = 50;
The first line is in the same for as the average blur which we made in step 5.
window.google_render_ad();
<<> - Next >>
More tutorials by Ross Aitken
Design a Web Template using the “960 Grid System” (29 December 2008)
How to Create an Abstract Photo Manipulation (10 September 2008)
How to Create a Movie Quality DVD Cover (10 November 2008)
Decorating Text (09 June 2008)
Retro Text (16 July 2008)
Active Writers
Denny Tang is the founder of Photoshop Tutorials and specializes in photo editing with Adobe Photoshop.
Oliver Cereto is a graphic designer and photographer from Málaga, Spain. View more of Oliver's work at olivercereto.com.
Ross Aitken is currently studying design at Glasgow, UK. You can find more tutorials by Ross at PSD Learning.
Become a writer
if (!window.netshel_ord) { netshel_ord=Math.random()*10000000000000000;
}
if (!window.netshel_tile) { netshel_tile=1; }
document.write('');
netshel_tile++;
document.write("");document.getElementById("img1").src="http://beacon.scorecardresearch.com/scripts/beacon.dll?C1=8&C2=2102&C3=303&C4=504310&C5=&C6=&C7=" + escape(window.location.href) + "&C8=" + escape(document.title) + "&C9=" + escape(document.referrer) + "&C10=" + escape(screen.width+'x'+screen.height) + "&C15=&C16=&rn=" + Math.floor(Math.random()*99999999);

Manipulate an Image with Scripting 3

Step 7:
This step is slightly more complicated, what we want to do is find the RGB values of the color we have in this layer. There is no really simple way of doing this in a script but the method I use is to have the script select first the red channel then get the histogram of that channel then go through the histogram from 0 to 255 until it finds a value that isn't zero then that value will be the R value, it then repeats that for the green and blue channels. It is easier to explain this by going through this process in Photoshop. If you don't still have the document open from when you tested it in the last step then run your script again. Okay go to the channels by going window>channels and select the red channel this should now hide all the other channels and the image will look grayscale. Next hit Ctrl+L to go to the levels adjustments, you will see a histogram with one vertical line in it, now drag one of the output levels sliders to roughly below the line and the number in the corresponding box is the R value. Getting the G and B value is done in the same way. The script to do this for the R value is shown below, from this you should be able to work out the code for the G and B value.for (RLevel = 0; RLevel <= 255; RLevel ++) {
if (docRef_1.channels["Red"].histogram[RLevel]) {
break;
}
}
This block of code is a 'for' loop, what line 1 does is says to start RLevel at 0 and keep looping around while RLevel is still smaller or equal to 255 and also to increment RLevel by 1 each time it loops around. The part which says RLevel ++ means increment RLevel by 1.
The part inside this loop is an 'if' statement and it will execute the command inside the curly brackets only if the statement within the normal brackets is true. Lets look at the statement within the normal brackets, its telling Photoshop to get the red channel in document one then getting the histogram array. The histogram that we looked at didn't look like a row of boxes but in fact it is, for each each output value horizontally from zero to 255 is a corresponding vertical value. In the histogram we looked at there was only one output value which didn't correspond to a non-zero value so RLevel can be thought of as the output value. since we haven't included anything else in the brackets like an equals sign or a greater than sign then it will automatically only return true if the value returned from the histogram is non-zero and since there is only one non-zero value then this will be the R value. The command to execute if this is true is the break command, this will stop the loop so we won't go round again after we find the correct value. the two closing curly brackets are just to close the 'for' loop and the 'if' statement.
Step 8:
Below I have included the full code up to this point, including the G and B value checks:preferences.rulerUnits = Units.PIXELS;
displayDialogs = DialogModes.NO
open(File(openDialog()));
var docRef_1 = activeDocument;
docRef_1.backgroundLayer.duplicate();
var white = new SolidColor();
white.rgb["hexValue"] = "ffffff"
var black = new SolidColor();
black.rgb["hexValue"] = "000000"
foregroundColor = black;
backgroundColor = white;
docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
docRef_1.layers[0].duplicate();
docRef_1.activeLayer = docRef_1.layers[0];
docRef_1.activeLayer.applyAverage();
for (RLevel = 0; RLevel <= 255; RLevel ++) {
if (docRef_1.channels["Red"].histogram[RLevel]) {
break;
}
}
for (GLevel = 0; GLevel <= 255; GLevel ++) {
if (docRef_1.channels["Green"].histogram[GLevel]) {
break;
}
}
for (BLevel = 0; BLevel <= 255; BLevel ++) {
if (docRef_1.channels["Blue"].histogram[BLevel]) {
break;
}
}
Now we are going to check to se if these last bits of code actually work, to do this we will use an alert box and make it display the RGB values. Insert this code below the rest of your code:alert(RLevel + ", " + GLevel + ", " + BLevel)
The alert box should contain the RGB values check these by double clicking on the foreground color then using the eyedropper. If the colors match then delete this alert box code and move on, if they don't match or it's not working just copy and paste the full code above and try again.
Step 9:
From now on I won't go into much detail as most of the things coming up have been covered already. Now depending on the average color we want to edit it in different ways. The way we will edit it is fill this layer with a solid color change its blending mode to color. The color of this layer will depend on the average color; if the average color is mostly blue we will use the color yellow, mostly green we will use magenta and mostly red we will use cyan. I'm going to show a long way of doing this just to demonstrate some extra commands. In this step we will get the RGB values for this color. The code for this is: var R = 0;
var G = 0;
var B = 0;
if (RLevel > GLevel && RLevel > BLevel) {
R = 255;
}
if (GLevel > BLevel && GLevel > RLevel) {
G = 255;
}
if (BLevel > RLevel && BLevel > GLevel) {
B = 255;
}
Here we are first defining the variables R,G and B and setting them to 0 then we have three 'if' statements so for the first one it is basically saying if RLevel is bigger than GLevel and BLevel then set the R value to 255. The same goes for the G value and B value, if in the off chance any of the values are equal then all values will remain 0.
Step 10:
Now we will create a new color then fill the layer in with this color, using exactly the same commands that we used in step 4 and 5. The code for doing this is:var color = new SolidColor();
color.rgb.red = R;
color.rgb.green = G;
color.rgb.blue = B;
docRef_1.selection.selectAll();
docRef_1.selection.fill(color);
docRef_1.selection.deselect();
The only difference is that we called the variable color, just because this could either be red, green or blue; in my case it was blue.
window.google_render_ad();

Manipulate an Image with Scripting 2

Step 4:
Now I will show you how to define colors using hexadecimal codes, colors can be defined in other ways like by RGB values as we will see later. Here we will define a white color and a black color then set black as the foreground and white as the background. There is other ways of doing this but for the purpose of this tutorial I will show you this way. The code for this step is:var white = new SolidColor();
white.rgb["hexValue"] = "ffffff"
var black = new SolidColor();
black.rgb["hexValue"] = "000000"
foregroundColor = black;
backgroundColor = white;
You will notice here that the first two lines are roughly the same as the second and third; what we are doing here is setting up a variable which can be named anything but here we use the color it will contain as the variable name. We are then saying that this variable is equal to new SolidColor() which is a function for creating a new color. The next line is setting the hexadecimal value for this color to whatever the color should be so for white this is "ffffff", what we are ultimately saying here is that white is the color white and black is the color black.
The last two lines set the foreground color to black and the background color to white, and are fairly easy to look at and understand straight away. In Photoshop the equivalent action for doing this would just be to hit D to reset the colors.
Try now, setting the foreground color and background color to a random color manually then running the full script which should give you the same result as we got in step 3 but now the foreground and background colors will be set properly.
Step 5:
Now we are going to fill the background layer white using the white color we set up in the last step. For this we first need to make a selection around the whole document then fill that selection. The code for this is:docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
The first line creates a selection using the selectAll() function, for any command that can be used on different documents we have to tell Photoshop which document we are working on even though we only have one open in this case.
The second line is telling Photoshop to fill this selection in with the white color. Sometimes it is confusing as it wouldn't be stupid to think that something like docRef_1.selction.fill = white would do what we are trying to do, but this isn't a real command and this is where ESTK comes in useful as it will point out the correct use of something like the fill command just by typing in fill.
The third line is fairly self explanatory, it will deselect the selection, exactly the same as hitting Ctrl+D in Photoshop.
Again test the script and you should end up with a white background layer and the image in the layer above. In Photoshop, all this could have been done using Ctrl+A then Shift+F5 to select all then fill the selection.
Step 6:
In the next two steps we will use a script to find the average color in the photograph; we will then use this information to decide how to edit the image. This part of the script could have lots of other uses for example you could use a similar script to create a color chart based on the colors that make up the image. In this step we will first duplicate the image layer then we will apply an average blur filter which will find the average color then fill the layer with that color. The code for doing this is:docRef_1.layers[0].duplicate();
docRef_1.activeLayer = docRef_1.layers[0];
docRef_1.activeLayer.applyAverage();
The first line looks familiar, we used the same command in step 3 but here we have replaced backgroundLayer with layers[0]. To understand this we need to know a bit about arrays in JavaScript. Arrays are simply just variables which hold more than one value, where variables are like boxes with a single piece of information, arrays are like a big boxes with lots of smaller boxes labelled zero to infinity inside. For example if you wanted to create an array holding the first three days of the week you would type:var days = ["Monday", "Tuesday", "Wednesday"]
Now if you wanted to use the first day of the week you would use the code:days[0]
This would equal "Monday"
Obviously don't include these last two lines in your script. Now that you know a bit about arrays we can go back to the three lines of code we added. In the first line layers is an array which includes all the layers in our document. The top layer in the stack is always the first in the array, corresponding to layers[0] because arrays start at 0 instead of 1.
The second line sets the active layer to the top layer this is the same as selecting a layer in the layer panel in Photoshop. We didn't need to change the active layer but it makes things easier later on.
The last line applies the average blur, the format here is the same as most of the commands we have used so far and is what's called a method and usually takes the form of document.layer.function where the layer is the active layer and the function is applying the average blur. This can be done in Photoshop by going filter>blur>average.

Manipulate an Image with Scripting 2

Step 4:
Now I will show you how to define colors using hexadecimal codes, colors can be defined in other ways like by RGB values as we will see later. Here we will define a white color and a black color then set black as the foreground and white as the background. There is other ways of doing this but for the purpose of this tutorial I will show you this way. The code for this step is:var white = new SolidColor();
white.rgb["hexValue"] = "ffffff"
var black = new SolidColor();
black.rgb["hexValue"] = "000000"
foregroundColor = black;
backgroundColor = white;
You will notice here that the first two lines are roughly the same as the second and third; what we are doing here is setting up a variable which can be named anything but here we use the color it will contain as the variable name. We are then saying that this variable is equal to new SolidColor() which is a function for creating a new color. The next line is setting the hexadecimal value for this color to whatever the color should be so for white this is "ffffff", what we are ultimately saying here is that white is the color white and black is the color black.
The last two lines set the foreground color to black and the background color to white, and are fairly easy to look at and understand straight away. In Photoshop the equivalent action for doing this would just be to hit D to reset the colors.
Try now, setting the foreground color and background color to a random color manually then running the full script which should give you the same result as we got in step 3 but now the foreground and background colors will be set properly.
Step 5:
Now we are going to fill the background layer white using the white color we set up in the last step. For this we first need to make a selection around the whole document then fill that selection. The code for this is:docRef_1.selection.selectAll();
docRef_1.selection.fill(white);
docRef_1.selection.deselect();
The first line creates a selection using the selectAll() function, for any command that can be used on different documents we have to tell Photoshop which document we are working on even though we only have one open in this case.
The second line is telling Photoshop to fill this selection in with the white color. Sometimes it is confusing as it wouldn't be stupid to think that something like docRef_1.selction.fill = white would do what we are trying to do, but this isn't a real command and this is where ESTK comes in useful as it will point out the correct use of something like the fill command just by typing in fill.
The third line is fairly self explanatory, it will deselect the selection, exactly the same as hitting Ctrl+D in Photoshop.
Again test the script and you should end up with a white background layer and the image in the layer above. In Photoshop, all this could have been done using Ctrl+A then Shift+F5 to select all then fill the selection.
Step 6:
In the next two steps we will use a script to find the average color in the photograph; we will then use this information to decide how to edit the image. This part of the script could have lots of other uses for example you could use a similar script to create a color chart based on the colors that make up the image. In this step we will first duplicate the image layer then we will apply an average blur filter which will find the average color then fill the layer with that color. The code for doing this is:docRef_1.layers[0].duplicate();
docRef_1.activeLayer = docRef_1.layers[0];
docRef_1.activeLayer.applyAverage();
The first line looks familiar, we used the same command in step 3 but here we have replaced backgroundLayer with layers[0]. To understand this we need to know a bit about arrays in JavaScript. Arrays are simply just variables which hold more than one value, where variables are like boxes with a single piece of information, arrays are like a big boxes with lots of smaller boxes labelled zero to infinity inside. For example if you wanted to create an array holding the first three days of the week you would type:var days = ["Monday", "Tuesday", "Wednesday"]
Now if you wanted to use the first day of the week you would use the code:days[0]
This would equal "Monday"
Obviously don't include these last two lines in your script. Now that you know a bit about arrays we can go back to the three lines of code we added. In the first line layers is an array which includes all the layers in our document. The top layer in the stack is always the first in the array, corresponding to layers[0] because arrays start at 0 instead of 1.
The second line sets the active layer to the top layer this is the same as selecting a layer in the layer panel in Photoshop. We didn't need to change the active layer but it makes things easier later on.
The last line applies the average blur, the format here is the same as most of the commands we have used so far and is what's called a method and usually takes the form of document.layer.function where the layer is the active layer and the function is applying the average blur. This can be done in Photoshop by going filter>blur>average.

Manipulate an Image with Scripting

Scripting in Photoshop is something rarely touched upon in regular Photoshop tutorials, but is something definitely worth learning. Scripts are a much more powerful way to automate tasks than actions and can be used to do things which normally aren't possible in Photoshop. Here we create a script which will edit any image, giving a stylish way to show your photographs.
Introduction:
In this tutorial I will aim to show how to create this effect using scripts but will also show the corresponding steps in Photoshop, making it easy for you to understand how to alter your script to achieve different results.
Photoshop allows scripts in three different programming languages; VBScript, AppleScript and JavaScript, however JavaScript is the only cross platform script available so we will use it, it is also more useful to learn JavaScript. If you haven't ever programmed in JavaScript, you should still be able to understand this tutorial as I have explained all of the concepts in enough detail. When writing JavaScript you are free to use whatever text editor which suits you, however newer versions of Photoshop come with a program called ExtendScript Toolkit (ESTK) which makes scripting a lot easier. This is usually found hidden away in the same folder that contains Photoshop. If you don’t already have this program then you can download it here although it may not work for older versions of Photoshop. There are a few advantages of using this program, mainly the debugger and the fact that you can run scripts straight from the program.
For most of the steps I will show what your image should look like after you have run the script. Throughout this tutorial I used this image from stock.xchng, optionally you can save a small size version of this image for the purpose of testing your scripts as the script will run faster this way. The script works for any image of any size.
Step 1
Open the editor you want to use, either ESTK or a regular text editor like notepad for Windows, don’t use a program like Microsoft Word for this. If your using ESTK then there should be a dropdown menu at the top left of the window, select Adobe Photoshop from this and this will link the program to Photoshop.
Now we will right a simple script to test we have the settings correct. Type the code shown below into your editor:alert("Hello World")
What this simple command will do is to bring up an alert box saying ‘Hello World’; we will use alert boxes throughout this tutorial in order to test parts of our script. By putting the quote marks in we are indicating that this is a string which is just a word.
Now run your script, If you are using a regular text editor like notepad then the easiest way to run your script is to save the file as ‘myscript.jsx’ then open Photoshop and go file>scripts>browse then select your script. If you are using ESTK then just hit the play button in the top right of the document window. Automatically you should see your alert box pop up. Before testing your scripts close any document that is open in Photoshop.
Step 2
Delete the alert code you had in the editor as we were only using it to test the settings. There are two settings we want to apply every time we run our script, these are to tell Photoshop to use pixels as the default unit and not to display dialog boxes unless we tell it to. If we wanted to do this within Photoshop we would go edit>preferences>units & rulers and change the rulers value to pixels, obviously turning off dialog boxes is limited to the scripting only. The code for doing this is:preferences.rulerUnits = Units.PIXELS;
displayDialogs = DialogModes.NO
The first command is, simply telling Photoshop to access the rulerUnits within the preferences then change the units to pixels. You will notice that this is arranged in a hierarchical structure for example the rulerUnits is contained within the preferences, this is easy to visualise as Photoshop is arranged in exactly the same way.
The second command is basically telling Photoshop to change the value of displayDialogs to NO, if you wanted to have dialogs displayed while running the script then you would change the NO to YES.
Step 3:
Now we want to let the user select a file to open, for this we need to bring up an open dialog box, even though we turned dialogs off if we tell Photoshop to bring up a dialog it will do it. We then want to define a variable that references to this document then we want to duplicate the background layer. The code for doing this is:open(File(openDialog()));
var docRef_1 = activeDocument
docRef_1.backgroundLayer.duplicate();
The first command is made up of three parts, the open() command which will open the file within the brackets, next the File() command which fetches the file path within the brackets but instead of adding a path we added the openDialog() command. So this is displaying a dialog box where the user selects a file then it will get the file path and open that file, if you were wanting to open the same file each time you could swap the openDialog() with the file path and name .
In the next command what we are doing is setting up a variable using var then the variable name which can be anything but here I used docRef_1, if I was to open another document I would make a variable named docRef_2. We are then setting docRef_1 to be equal to the active document.
In the last command what we are doing is telling Photoshop to duplicate the background layer in docRef_1 which is the only document we have open anyway. You will notice again that this is similar to what you would do in Photoshop, as in you would select the document which contains the layer you want to duplicate then you would select the layer you want to duplicate then you would duplicate it.
Try running the full script now and you will end up with a background layer containing the image you chose and also a layer above that containing the same image.
To do this step in Photoshop you would simply go Ctrl+O then choose your file then right click on the background layer and select duplicate layer.
window.google_render_ad();