12:45 pm - Introduction to Variables
Variables is somewhat similar to what we did with layer cops in that you could do some of the same things but it's actually much more versatile what I'd like to do is I want to create templates and photo shop I'm going to create a photoshopped file that might represent let's say a business card and then I have a company that's got twelve hundred employees and I need twelve hundred business cards so I might be able to talk to the human resources manager to get a spreadsheet that has each employee's name their position at the company the address they wanted their business card the phone number and let's say we're something like a realtor or were even photoshopped trainers in some of them are certified and some of them are not so I need a badge a logo to show up that shows those that are certified in those that aren't and if it's a realtors business card oftentimes they show their own photo on the business card so I want to create a template for that business card that has all those eleme...
nts already created I decide the funds I want to use the sizes, the position and all that and then I want to be able to take a simple spreadsheet file or text file even that of mike it from the human resources department feed it to photo shop and have photoshopped create one file for each entry in that so if we have twelve hundred employees were going to end up with twelve hundred files and we just need to create the template in set it up right? And then once we tell it to create those files we could literally goto lunch we come back we have twelve hundred business cards made for us so not just for business cards though you can use this if you want to make the look of a baseball card for like let's say high school teams who want one for each position you could do this for let's say you shoot babies or something you can create little templates of different layout and then have it automatically insert photographs into those layouts in create files so you don't have to be going in and out of photoshopped that much you're just feeding it little text files which tells us what to do so it's pretty cool so let's just look at the concept first so conceptually and the a case of a business card let's say that this is the information factory open this so it could be a little bigger let's say this is the information the human resources department gave me and I need to make business cards so this is all they gave me it's the individual ploys names their address phone number and email that's it and we just have a top line in here just identify what each column within this means now this is the kind of information we need to feed photoshopped. The only thing is, it actually doesn't need to be a spreadsheet file. This isn't a spreadsheet because the way it's laid out like this, in fact, what it really needs is a text file, just pure text. You'd have the same data in the text file, and the only thing is you either have a tab character in between each one of these entries or a comma, either one it can handle both. So the way that that would look if he looked at just a pure text file is like this. This is the exact same information. The only difference is, instead of showing it in columns that line up instead there's a comma between each entry, that's here and that's. What tells photo shop, where one entry starts in the next one, begins, but this could just as easily be tab characters instead of the comments it can handle either one. Now I usually set up this information in a spreadsheet because I convert you it in this way. I'm not a numbers person, I'm a graphics person, so like most people watching, probably you might not even have a spreadsheet on your computer because you're a graphics person, but you can get a lot of free ones online where you can type this information in all you need to do is if you have a spreadsheet program and you can type in this info there's, usually an export feature in the export feature you can often tell it to give you it was called a comma delineated file or a tab delineated file. I'll show you how to do that in such in a few minutes. So anyway that's the kind of information we're gonna be able to feed photo shop, and then we're going to create a template. The template might resemble this for a business card, where in this file I would end up creating one layer for each piece of the file that I would want to be able to change out with new data so I would have one layer for the name. I would have one layer for the address. I would have another layer for the phone number in a final one for the email, because that's the information that was in that other file, if I can create a template like that with one laywer for each of those items I want to swap out, then we could have a graphic designer or anybody else create that template and we just need to do a little bit of work to make it so it knows that if I feed it a tax file which one of these fields should change and so let's see how it's done I'm going to start from scratch though, so I just create a brand new file and whatever size you think you you want I don't remember the size of a business card is it? I'm going to say four by two and a half I don't know if that's the right size or not whatever size you want to be a brochure could be anything all right, so here this is going to represent my file I'm just going to make it as simple as I can to start with and then we'll progress to make it more and more interesting so I'm simply going to grab the text tool I'm going to click here and just say headline because that's going to be something I want to change I just have that one extra layer in there other than the background and now I want to tell photoshopped that this is a layer that I want to be able to vary by feeding it a text file to accomplish that with that layer active I'm going to go to the image menu and that's we're going to find a choice called variables and I'm going to find that is a variable of variable is simply a layer that can vary based on the contents of a tech file, so I'm defining this variable when I do this comes up and at the top of just is gonna list all the layers during my file that could very the background layer is not something you can vary so doesn't show up, but if I had more than one tax player more than one would show up in this menu it should default whatever layer I believe it's currently active and then down here are the different ways you could vary that layer I could vary the visibility of this layer so aiken make it either show up or become hidden. I might do that if I have that little certification badge that I mentioned for realtors or other things, but I want to do a text replacement variable, so that means it will be able to swap out the some other text I need to give the variable in name. Do you remember in the spreadsheet that I showed you the very top line of the spreadsheet had words like name, address, phone that's going to be the names of the variables all it is is an identify wr that says, what is the first line of information in this data? Is that the name field or what is it I'll call this headline and then I'm gonna click okay, now we've done all we need to do in order to prepare this image I'm going to save it on my hard drive just like case I screw something up on get back to it and I'll put it on my desktop photoshopped file formats fine okay, so I got that saved nothing weird we just have a text layer I went up to the image menu chose variables to find it it's a variable called headline now what I'm gonna do is I'm gonna open a spreadsheet program uh, we're actually let's not even use a spreadsheet program let's use um see if I can find it it's going to text hopes text that it will just use text edit it's a free program that comes with the mac uh and I'm going to say create a new document that way we're not even using a spreadsheet yet texted it and I'm just going to put the very first line of this text file it's going to be called headline then I'll hit the return key and I'll type in whatever I want my headline to be so I'll say hit the return key and I'll put in another entry and I can put it in his many of these as I'd like, I don't know if I spelled that ribbon right? I'm not paying attention um okay, so I have four entries here now I'm going to save this file just gonna choose save and if I use photo chopra not push if I use just a text for matt let's see if it just has text well rich text document I'm assuming that worked but the problem is rich text means it has formatting in it. What I would really like is plain text meaning I want the simplest thing in the world I want literally just this text so I'm not used to using text that it will end up using a spreadsheet in a moment, but I'm going to just call this data and let me see what happens with the ricks rich text format hopefully it won't have to much formatting in it because that would mess things up. I wanted to have simply this information if that doesn't work, we'll just put it in a different form in a different program that can that export things even simpler than that. So I'm going to look at my hard drive it's sitting right there if I hit the space bar this is thie content that's within it hopefully doesn't have a lot of formatting information we'll find out if it does it's going to give me an heir message, so now I'm gonna go and switch back over the photo shop we got this that set up and I could go back up to the image menu I can choose variables and you choose data sets. A data set is simply a text file that contains the set of data you'd like to use to swap out if I choose data sets there's an import button on the right side. If I hit import, I can tell it to go grab that file. I'll just hit select file, and in fact, it can't deal with that rick rich text file you see it's great out, so let me do something that will make that even simpler. I usually use a spreadsheet uh, they're spreadsheet that I happen to own this one that comes from apple, but you can use just about any brand of spreadsheet I'm going to create a brand new one, and I'm just going to put us my first line headline, I gotta spell it right though below that I'll put in whichever, uh, data I want, so I'm just typing in a bunch of data now. The problem is, if I save out this spreadsheet what's gonna happen is all these empty fields that are here it's going to come in and put entries in for those where I have to grab this little dude out of the lower right, imagine it's like a crop. Feature if I grab that and pull, I can pull it in like this to say only give me what I have unfortunately I can't pull it in even further I would love to pull it in one more tick mark over there because we don't want this empty field what it's going to dio is it's going to give me just an entry in my text file? That's called headline it'll have a comma and then an emptiness it'll hit return it'll have the second one a common to say there's another field and then a return it's the comet that would mess things up what I can do in here is if I I mean the only time I use variables I always have more than one and so it be very rare to have just one so here I'll do headline and then I'll put in um subhead and below that we can put in entries for that that way we won't run into that limitation just filling it up with some data. Now I'm going to save this they're saving in two ways. First I'm just gonna choose save and I'll save it on my desktop and whatever file format that this program would default to that way I can open it up and we'll stay in the formatting that too used to and I'll just call this data ben just so I can remember and then I want to get it in the format that photo shop khun deal with to have it so photoshopped can deal with it it needs to either be a comma delineated file where the tab delineated one and to do that in numbers what I do is go to the file menu I choose I believe export and you see this choice called c s v c s v stands for comma separated values if I remember crack all it means is a text file it has commas in between the values, so I'll choose that the encoding doesn't matter and I just hit next and save it out I'll use the same name it'll just end with the letter c s v I know photoshopped can handle a csp file because this is how I usually create them right here in the spreadsheet called numbers now it's got a photo shop the only thing in photo shop is you know how we had two entries in that file we had a second ago? Well, you need to have the exact same number of variables to find, so I'm going to come in here and add a second text layer that that one's called headline this one's going to be called subhead and I'll format it so maybe I make the size smaller and I could bury the text possibly and then I'm going to find that is variable go to the image menu, choose variables to find so we'll find the layer called subhead is a text replacement and I need to make sure that whatever I taping right here it's exactly the same as what's in that spreadsheet that I created, I believe I called it subhead. We'll find out if we did it in a minute. Click okay, so now I have those two layers they're both defined. I also have on my desktop a file right here that if I preview, contains this data where one is called subhead, the other is called headline let's. See if I can feed it that to get it to change out my image. All right, so we're gonna photo shop. We go to the image menu good of variables. Instead of defining them, we go to data sets and if I choose data sets there's an import button on the right and just choose select file in feed it that little c s v file you could handle a file. It ends in t x t like a text file or c s v stands for camera separated values so it should work fine, then leave the encoding it automatic. It will figure out any kind of formatting that's in there and deal with it and then click okay now, let's, see if this worked I'm going to turn on the preview checkbox in the right and when I do it should take the first data set me in the first entry and replace the text with it so when I turned on preview do you see how it just replaced that text? But we had more than one entry I don't remember how many we had in there if I want to cycle between them there is little right and left uh arrow keys here where it's going to switch out each one as I go through this and just cycle through them all and we just start back over again once it gets to the end but you see it's working that's not so now let's get a little bit more complex so we have those that are just controlling what's this text going to contain now let's try a visibility variable I'm going to create a background in here just going to go down to my adjustment layer icon and I mean to say put a pattern in and we could use that checkerboard we made that's kind of beautiful, but I think I'm going to use something more like diamond plate uh or one of these other choices some really funky backgrounds will use that not trying to make a gorgeous image I'm just trying to show you how you can do this, then I'm going to define it as a variable again, I go to the image menu choose variables into fine it should remember what layer is currently active and automatically choose it from this menu, but if it happened to have the wrong layer active, I could click here it'll list all the layers that could be varied if you see an ass tricks after the name, it means it's already a variable if there's no asterix hasn't been defined yet, this one, I'm going to set a visibility variable and I'm just going to call it texture click okay, now, let's, go back to our spreadsheet, I'll just go right back here to numbers, and what I'm going to do is expand this out, so we have another column there and I'm gonna at the top put in the word texture, because isn't that what I called the variable below that I'm going to put either the word true or the word false true means make that that layer show up false means hide it usually it's all caps is what I use, so only one of them hasn't said two false expand this out so you can see it better. All right, so now I'm just going to type command us to save it back in the file format, the default file format, and then I'll export cause I really need it when those comments in it and I'll just save over the one we had it a moment ago so always that it is one more common here called texture it says true or false now let's go back to photo shop and see if it works so I go to the image menu I choose variables and let's force it to use ah data set again on the right side we have the import button like the file grab that file in my desk top click okay now I have to turn on the previous check box and let's cycle through these and see if that background disappears on any of them see it gone now it's back announce back because I think it was only one of them that I had a set to false so only on one of these entries will have hide that layer that's pretty cool and that we could hide the layer but that's not the only kind of variable we can have waken have that one where various attacks we have one word chooses if a layer is going to be visible or not but we can also make it switch out different photographs so I'm gonna just go find a photo any photo? I don't care which one see if I can find we'll hear the look of these dorks let's get that one all right I'm just gonna use the move tool or I could copy and paste select all copy in this document comand venus paste. All right, I can scale this tiny size. I'd like just type command tea for transform and let's say position at anywhere I want. Now I want to be able to switch which photo is displayed there and to do that, all I'm gonna do is go up to the image menu, choose variables, and I'm going to define that as a variable. So it remembers what layer was visible or not visible active so it automatically highlights it. I go over here and it's, not visibility. I want to turn on and off between these. I want to switch which picture is in there? That's called a pixel replacement uh, variable, and I'm just going to come in here and call that photo and then since I can feed it any size photo, I want a vertical or horizontal or whatever he wants to know. How should it fit within this shape of the original photo that's in that layer? Should it use a setting called fit fit means scaled down so it's no larger than this area, but don't crop anything you know, use the entire photo but fit within the original bounds of this image, phil means scale it until it fills this layer. And you might need to cut off some stuff, because if it's a vertical photograph in order to get it to fill the hole with it might cut off the top and bottom a bit to fill that you can see a preview down at the bottom when your have your mouse over this as is means don't change the size, use whatever size, image your feet it and then you can choose conform in conform means scale the width and height to be exactly the size. So even if I fed it a really wide panorama, it would squish it to be this with that's only useful if you have kind of abstract things like water textures or some other thing. Um, so I'm going to see us put it in here as fit that way it might not cut things off or I can use phil whichever of the two you like now, you also have a choice over here called alignment so let's say I choose fit that's where it's going to scale it down without cropping at all and fit it within their well. The alignment says, compared to the picture you already have in there is a place holder should align it with the center should have put it in the upper right corner of that lower right corner or where so I'm gonna have it centered on where this is or if I look at my layout is kind of in the corner of the document will want to keep it snugged up in the corner I'll just tell it upright corners where should align? Remember I called this photo the very well click okay, now let's, go over to our spreadsheet let's add another one of these columns and we're going to call that one photo and below that I'm going to type in the file names of the photos that I'm going to use I'm just going to keep it simple by colonic one dot j p g two dot j p g three dot j, p g and four dot j p g now these have to precisely match if you have upper case j pegs on your images, these need to be upper case if you have a space and something that has to have a space it has to absolutely precisely match otherwise it will mess up, so I'll save this and that'll export it again as our comma separated values just save over the original just wiped over the original and so this is the data we're going to use now I need to find some photos I need four of them and I need the file names to mash this so let's go over the bridge and see if I can find for photos well, look at that we got four right there, so I'm just going to take these four photos and they need to be in the same folder it's where that text file is the text file sitting on my desktop right now so I'm just going to drag these to my desktop I happen to have my max set up so I can drag the lower right corner of my screen to see the desktop if you don't have anything like that setup up here I have desktop that could have dragged it there let's go look at her desktop and I see the files but the file names aren't what we need so I'm gonna click on one of those and change the file name toe one dodge a peg if I hit tab it'll take me to the next picture to dot jpeg come down here to these two three dot j peg and this one for dodge a pick those air the file names now on my desktop hopefully that matches what's in that spreadsheet and if so, this should work let's go to photoshopped uh we've already defined the variable I believe so all we need to do is choose image variables data set and we need to go feed it that file again same way we did before when we hit import, then the other button grab that file and this should have all the data we need. I'm going to see if it works, though I'm going to use the right and left arrow keys that air here or there's a previous and next button on the right and let's, see if it works. Do you see how it switched out the photo? Remember the second entry had the texture set the false, so it hid the background. Go to the next one, see how it took a second for it to go and find that photo and swap it out, but we can do all this so it's working. So, so far, we've used what kind of variables we've used, a text replacement variable. We've used a visibility variable, and we've used a pixel replacement variable. And, in general, those air, the three kinds of variables that you can use.