Facebook Like

us and stay connect with Onextrapixel on Facebook.

Photoshop Variables: How to Import External PSD Smartly

When working on large projects, with many mock-ups and style-sheets, even the smallest change on a re-occurring component can take quite some time. Going through the many mock-ups and adjusting a color or font on that re-occurring component can be a grueling task. If you have an intern that does those things for you, you are in luck, but what about us freelancers?

Photoshop Variables

Do we just sit there and endure the pain? Well, not anymore! A while back, I discovered a system that enables designers to say goodbye to opening 23 PSD files just to change the header color. Instead, we can work smart, like our counter parts the developers, and import external files with something called - “Variables”.

This allows us to put the re-occurring component into one external file and simply import that file into all of our mock-ups. When a change is required, we can just change it in one place.

What is a Photoshop Variable?

Here is Adobe’s technical explanation for a variable. A variable is basically used to define which elements in a template change. There are three ways to define a variable.

  1. Visibility Variables - Shows or hides the content of a layer.
  2. Pixel Replacement - Variables that replace the pixels in the layer with pixels from another image file.
  3. Text Replacement - Variables that replace a string of text in a type layer.

You can read more about variables here: Photoshop Define Variables

For our needs, we are going to focus solely on Pixel Replacement, since what we want to do is import an external style-sheet into our PSD.

Lets Get Started

Step 1 - Setting up your files

In this step we need to decide which component in our homepage deserves a variable. In most cases, it is better off creating a variable for a component that re-appears in many different mock-ups. These components can be headers, footers, various sidebar widgets, and anything that re-occurs in the project. In our example, we will use the global header.

Welcome

There are usually many different states to a component (for example, most common is logged in / logged out). This being the case, style-sheets are created for the component, illustrating the states. Ideally, we want to import the component’s style-sheet and make it fit seamlessly into the mock-up. This will provide us with one file acting both as a style-sheet, and as an embedded file that will be imported into all the mocks the component appears in.

Component Global Header

I have created a fake style-sheet for the global header called 'Component_GlobalHeader.psd'. To continue on with the rest of the steps, please Download it.

Step 2 – Setting up grounds

Let’s open our homepage mock-up and create a new layer. We will give it the same name as the style-sheet's file name, in our case 'Component_GlobalHeader.psd'. Let’s call this new layer 'Component_GlobalHeader'. This is the layer we will be importing the external file to.

Setting Up Ground

Step 3 – Creating the variable

Now it’s time to create the variable. We do this by going to image > variables > define. A popup will appear and we are going to edit some of the parameters.

First of all, always double check that the layer is indeed the correct one (the one we just created). You can check that in the ‘Layer’ field. If it is the incorrect layer, it may cause a bit of a mess later on.

Variable Menu

Since we are focusing on importing, we will go straight to the 'Pixel Replacement' option. In the 'Name' field, enter the same name as the layer and external style-sheet. It is healthy to keep every name the same as this will help with organization in the future.

Creating The Variable

Next, we are going to focus on ‘Method’. We are going to choose a method for scaling the replacement image/file. There are a few options here:

  1. Fit - scales the image so that it fits in the bounding box (which may leave parts of the bounding box empty).
  2. Fill - scales the image so that it fills the bounding box entirely (which may cause the image to extend beyond the bounding box).
  3. As Is - applies no scaling to the image.
  4. Conform - scales the image disproportionally so that it fits in the bounding box.

What we want is 'As Is' since we do not want to manipulate our external style sheet.

Pixel Replacement

The 'Alignment' can be left as the default middle, but this is a personal preference as well as a component consideration. I have aligned top-left in the past as well. It really depends on you.

Let’s leave 'Clip to Bounding Box' unchecked.

Click Next.

Step 4 – The actual importing

In order to import the file, we need to either choose or create a new 'Data Set'. Data sets are collections of variables and associated data. You define a data set for each version of the graphic you want to generate. So if you have many different sidebar widgets in your mock-up, all generated from the same external file, you would only need one data set called 'sidebar_widgets'.

Since we don’t have any previously created data sets, let’s start by creating a new one. To do this, click on the small disk/arrow icon on the left of the trash icon. Now that we have created a new data set, let’s give it a name. Yep, you guessed it. Let’s give it the same name as the variable, layer, and external style-sheet file. As I’ve said before, they should all be the same name.

Data Sets

Do Not Replace

Now that’s done, we can upload the external file. Click on the 'select file' button in the 'Value' section, and choose 'Component_GlobalHeader.psd'. Notice that if you have 'Preview' checked (on the right, under the apply button), you will see the new style sheet appear on your homepage mock-up. Super important: always remember to click 'apply' before clicking on 'OK'. If you do not do this, all that we have gone through would be lost and you would need to redo everything. So remember CLICK 'APPLY', then click 'OK'.

Select File

We have successfully imported the external style sheet into our homepage mock-up! Yay! But wait! We now have this massive layer, but need only part of it.

Homepage Mockup

Step 5 – Masking

Since we don’t want the whole style-sheet to appear in our mock-up, we can basically mask the part we need and hide the rest. We will do this by creating a new shape layer in the same dimensions as the component we want to show. Now to get the shape layer to mask it, all we need to do is drag the mask onto the component layer. You will now see the whole screen filled by the shape layer since we removed its mask. Delete the un-masked shape.

Masking

Step 6 - Updating

Now that you have an external file, let me show you how this is useful. Let’s say that the red selected state on your global header just isn’t working for you and you’d like to switch it to blue. Simple! Go to your original style-sheet 'Component_GlobalHeader.psd' and change the selected color to blue. Save the file and go back to the homepage mock-up. Click on image > apply Data Sets and choose the data set that you would like to update. You will automatically see the change right away.

Updating

Disadvantages

Along with its potential, keep in mind that this is still considered a hack. Until Adobe decides to create a built-in system for importing external PSDs there will never be a foolproof way to do it.

One major disadvantage is that changing a component PSD and saving it will not automatically change it in the mock-ups associated with it. For example, this means that you will always need to 'apply data sets', when opening the homepage mock-up. Though this is something I have not tried, this problem might be able to be solved by creating an action of some sort, making the PSD open and automatically ‘apply data sets’.

Another disadvantage is the folder structure. Moving a file into a new folder tends to mess up the configuration thus creating an error when 'applying data sets'. Since it is random I haven’t found a way to work around it.

With those issues in mind, I still believe that this system saves countless hours of grueling hard labor. You need to know when to use it. Most of the time, it is used only with projects that contain more than 15 to 20 mock-ups.

Conclusion

This example is just the tip of the iceberg. You can see for yourself the amazing potential this system has. Be creative and experiment. Why not try adding sidebar widgets with only one data set?

Posted on: January 27th, 2010

Yaron Schoen

Yaron Schoen is an experienced designer, art director and digital artist living in Manhattan, New York. Specializing in many different fields of design with a primary interest in Web & Application Design, Yaron is a veteran in the field and has been in the industry for 11 years. Currently, his focus is on freelance work and entrepreneurship. You can visit his site below or follow him on twitter.

Share This Article

  • Share
  • Delicious
  • Stumble Upon

11 Comments & 9 Pingbacks | Add a Comment

  1. RasterBoy
    January 28, 2010 at 5:24 am

    Nice article. Thanks for the information.

  2. Olisen
    January 28, 2010 at 3:10 pm

    Great! I'm sure to try these techniques out. Thanks for sharing! Appreciate it!

  3. January 28, 2010 at 6:06 pm

    For things like this I recommend use Fireworks. A tool like "Find & Replace" is a great time saving for changing fonts, colours, objects...

    Just and idea. Nice article BTW :)

  4. January 28, 2010 at 6:18 pm

    Is this "trick" just the same as the "Place" function?

    • January 29, 2010 at 9:17 am

      Yes it is very similar, but the variables trick is a bit more powerful. You can create multiple layers that use the same data set for example. This is good for side bar widgets, for example.

    • Kostas Di
      January 30, 2010 at 3:09 am

      With "Place" the external file becomes useless and any updates must happen inside the smart object created. This can be memory intensive from time to time and each time you save, the main file has to update too. Although this method has more steps into it, it allows you to work on each component independently and store them as separate files.

  5. January 29, 2010 at 3:30 pm

    Hi Yaron
    Thanks for sharing this with detailed stuff with snapshots.

  6. June 4, 2010 at 2:52 am

    Thanks for this. I've always wanted to check out the variables but never came around to it.

    I'm however running into an issue that I can not solve. Each time I close my document, it loses all of the data sets I created. Is there a place that I can save these and/or stop them from disappearing at the end of every work session?

  7. June 17, 2010 at 2:37 am

    Thanks for sharing this!
    I've made an action in photoshop to apply data sets. From this action i created a droplet (File > Automate > Create Droplet). Now i only have to drag my PSD's that have to be altered on this droplet, and they are updated in a blink of an eye. It saves a lot of time!

  8. Hans
    July 2, 2010 at 2:26 am

    Thanks, this is really usefull. One question: Every time I re-open my photoshop files containing the header which is a variable I need to define the dataset again. Is this just the way it works or am I doing something wrong?

    I also tried to automate the process but the actions done in the dataset are not recorded in my action. Anybody know what that is?

    • July 4, 2010 at 6:21 am

      Hans,
      Defining the dataset every time you re-open a Photoshop file isn't supposed to be needed.
      It seems like you're missing one of the steps above?

      If everything is set up the right way, you only have to use the 'image > apply data set...' option in order to update your PSD containing the header PSD variable if it has been altered.

Please note that comments are moderated - and rel="nofollow" is in use. Please no link dropping, no keywords or domains as names. Kindly do not spam, and do not advertise!