Join Deke McClelland for an in-depth discussion in this video Real-world script 2: Preferences Unifier, part of Photoshop CS2 Actions and Automation.
And I'm changing default settings, by the way. If I feel like a default setting is a good setting, then I'm not changing it. If I feel like a default setting is a bad setting, then I am changing it. So, one of the default settings that I don't really like, that I actually extremely don't care for, is that Export Clipboard, inside the Preferences dialog box, is turned on by default, which means that if you copy a whopping big image inside of Photoshop and you switch to a different application, it takes a long time for the switch to occur, and, as often as not, the export fails, and you end up getting this error message.
And on the Macintosh side, you get this error message, you click OK, and you're flipped back to Photoshop again. And then you got to switch back to your other program afterwards, so it's a big pain in the neck. And, so unless you're specifically interested in taking your clipboard to a different application from Photoshop and copying things from Photoshop and pasting them into a different program, then you should turn that option off. And the way you do it is to go app, which is Photoshop, right, preferences, which is a property of the application. It's actually one of those classes that has a capital P when it's its own class, but when it's a property of app, it gets a lowercase p.
And here, if I go back up, here's exportClipboard. And it's Boolean, meaning that it can either be true or false, that's it. And then it tells you that it's a read-write, meaning that you can write the function, that is, you can modify the function from the script, and you can also check what the function is from the script. That would be a read. And it's an indication of whether to retain the, oh, I already told you what it is. You can read that if you want to. But you know what that does. So, this is a documentation of every single one of those properties.
And you can add your own very easily to this script. If you have other sort of pet peeves, like, hey, I want to make sure Smart Quotes is off, for some reason. That's a Boolean function, and you would just have to add a line of code into that script that is basically, works to the effect of app.preferences, and, of course, you can copy and paste, instead of re-entering, if you want to. What was that, smartQuotes, I believe, is what it was called. And I'm doing exactly what I told you not to do. What I told you to do back in chapter nine was to get the exact spelling and the exact capitalization of each one of these words by selecting the word, pressing Control + C, and then going back into ExtendScript Toolkit, and pasting that in there, just to make sure you got it exactly right.
Equals, let's say, false, semicolon, all right, if that's something that you wanted to do. Then, app.preferences.keyboardZoomResizesWindow I set to true. I really don't like this default setting as well, because it's different on the Mac and the PC. On the Mac, when you press Control + plus or Control + minus, you not only zoom into the image, but you change the physical window size as well. So you make the image window bigger as you zoom in, and smaller as you zoom out. On the PC, this option is turned off by default. Now, I see no reason for it to be off by default.
This is just me, you may have gotten used to it some other way, but I see no reason for it to be off by default, because if you want to zoom in and out without resizing the window, then you use the Zoom tool. So, that's the difference between the Zoom tool and zooming from the keyboard. Seems to me, anyway. So I go ahead and set this to true for both platforms. UseShiftKeyForToolSwitch, I set to false. That's turned on by default. I don't like having to press the Shift key as I press a letter key to switch tools. For example, by default, you have to press Shift + M to switch between the two marquee tools, the rectangular and elliptical marquee tools.
And I would prefer just to press the M key. And there's tons of other examples as well. So, I turn this to false. Again, these are just all my preference settings, and if I had a department, this is the way I would change them. App.preferences.interpolation = ResampleMethod.BICUBICSHARPER, more and more these days, when I am resampling an image, it turns out to be a low noise image, an image that's in really, really good shape, so when I sample it down, I like the default setting to be Bicubic Sharper, and that way, when I downsample the image, I don't have to follow it up, necessarily, with an application of the Smart Sharpen filter.
In the next panel, actually, of the Preferences dialog box, there's this function that's maximize compatibility when saving PSD files, layered PSD files. I set that to never, QueryStateType.NEVER. Notice this is a different kind of response. Both ResampleMethod.BICUBICSHARPER and QueryStateType.NEVER. And if we want to research those inside of the documentation here, I'll go up to max, let's see, where it is, right there, maximizeCompatibility. And notice, QueryStateType is something that you have to specify, and you have to decide whether it's going to be one of the options that actually appears inside the dialog box.
So, let's go over to Photoshop here. This is an image I just have open in the background, just so that we have something going on instead of the gray screen. This image is called Alsace walls, and it's inside the 10_scripting_2 folder. I'm just telling you that, though. There's no reason for you to open it. But just so that you know, I did give it to you. Control + K to open the Preferences dialog box. And then I'll switch to File Handling here, and notice our options for Maximize PSD and PSB File Compatibility are Ask, Always, and Never.
So, those are the ones that we have to choose from. By default, it's set to Ask, and that means every time you save a Photoshop file, every time you save a layered PSD file for the first time, this dialog box is going to come up and ask you whether you want to maximize compatibility or not. And basically, it's, generally speaking, a bad thing to do, 'cause it just balloons the size of your file. In addition to saving all the layers, it also saves a flattened version of the file along with them, and what's the point of that? Some other applications out there, including the likes of Premiere and InDesign, even, when they see a PSD file, they like to have Maximize Compatibility turned on.
But InDesign doesn't necessarily require it, so, I don't even do it for InDesign. Premiere does, but you'll just have to decide. If you have that kind of workflow, you got to turn it on. But why set it to Ask? That just creates more time for you, and it just wastes your time. Anyway, so those are the things you might set it to, Ask, Always, or Never. So we'll cancel out, go back to ExtendScript, and that's why I've got it set to NEVER, all caps. And that's just what it wants. How I figured that out, I don't even know, but I know I figured it out inside the documentation. It's in there someplace.
Next, we've got app.preferences.rulerUnits = Units.PIXELS. I like to work in pixels. And a nonLinearHistory = true. Now, that's not even inside the Preferences dialog box. And I don't necessarily like having Non-Linear History turned on, but I just went ahead and included this one to demonstrate that there are a few preference settings, a very few, that fall outside of the Preferences dialog box. And this is one of them. This option happens to actually reside in the History palette. You go to the History palette, and you choose History Options, in order to get to this Non-Linear History function right there.
All right, so I'm going to cancel out of that, but that's where that comes from. And those are my preference settings. I also include app color settings. If you've taken the time in order to create some unified color settings in your department, you would want to put those in the quotes instead. For example, I'll go back here to Photoshop, and I'll bring up the Color Settings command. I'm going to press Shift + Control + K, or I could just go up to the Edit menu and choose Color Settings. That's Command + Shift + K on the Mac. And let's say I wanted to specify my own custom settings.
What I would do is set those settings, like, for example, I like working from North American Prepress 2 as a base, but then I'd go ahead and turn all these checkboxes the heck off. I don't go ahead and preserve an embedded profile for grayscale images. I typically just leave that off. Because grayscale images can often be thrown off by profiling them, and I'm not going to go into a lot of detail there, but I just go ahead and turn that off. And then, you'd want to save out your settings. Click on the Save button. And I'll go ahead and call these settings Best workflow. That's what I like to call these settings, because that's what I believe them to be, is Best workflow.csf.
Notice it's best with a capital B, and workflow with a lowercase w. I'll go ahead and click Save in order to save out those settings, and then I could enter some text right here, some description text. For now, I'll just put a bunch of Xs in there and click OK. I don't want to spend a lot of time creating my description, but notice it is a good idea to do it, because when you hover over, look at the bottom of the dialog box, it includes a nice little description, so, if you were really doing this, go ahead and include a very thorough, very detailed description so other people know what you're up to. All right, now, click OK.
Do whatever you want with the color settings. And then, finally, what we got here, these are the foreground and background colors. So, go ahead and reset the foreground and background colors to black and white. (chuckles) It's totally unnecessary, as it turns out, when you launch the program, if you associate this Preference Unifier with launching the program, then it's not necessary to go ahead and switch the foreground and background colors to black and white, because they already are that way. But, if you want to run the Preference Unifier during the middle of a session, why, then, it's actually kind of helpful.
You can just read through this, but this is how you specify the foreground color, by the way. And zero red, zero for green, zero for blue, is black, and then, this is how you specify the background color, and 255 for each of the r, g, and b values is white. Then, what I go ahead and do is I say, after specifying, these are variables, by the way. I'm setting up these variables. Then I set the foregroundColor to foreColor, which I defined right there, and then I set backgroundColor to backColor, which I defined right there. Now, this is the part that I lifted from the reference guide, and what this does, you'll see in just a moment, but, basically, brings up this message that tells you, welcome to Photoshop, this version, it grabs the version number and tells you exactly which version you're using.
And then it's finding out all kinds of additional information here. It's telling you where the program is installed. It's telling you the amount of memory that's available to Photoshop, the amount of RAM that's available, how much memory is free at the current moment, and it's actually rounding off the memory. Some of this, I did myself. I actually modified this code a little bit, because notice that what it's doing is it's telling the amount of free memory, and it's doing it in bytes, which means that there's just a ton of numbers in there. Then, I included a little thing in parenthesis that rounds off the math, that's Math.round, for this app.freeMemory number, and I divide that by, what would that be, 1,048,576, which is what you need to do to convert bytes into megabytes, believe it or not.
Here's the reason. There's 1,024, all right, there's 1,024 bytes in a kilobyte, and then 1,024 kilobytes in a megabyte, and when you multiply 1,024 by 1,024, you get 1,048,576. Just happens to be the way it is. I wanted to give people the real number instead of just dividing it by a million. And then, we have some other stuff going on here as well. You can include this code, or not include this code, depends completely on your preference at this point.
What I'm going to do, I did make a few changes, so I'm going to go up to the File menu, I'm going to choose the Save As command, and I'm going to go ahead and save this as Preferences Unifier, of course, inside of Your scripts baby, which is what I encourage you to do as well. That's inside of that 10_scripting_2 folder. So go ahead and save that out. That is done. Now, why don't we go ahead and play this script and see what happens here. I'll restore this down. Let's set up some things a little bit differently here. Let's try some stuff, like turn on Export Clipboard, turn off Zoom Resizes Window, turn on Use Shift Key for Tool Switch.
I'll go over here, make sure that this is set to Ask. Were there any other things? I think there's some other stuff going on. Oh, if I go to the fifth panel, I can set the ruler units to inches. All right, and then I'll click OK, and I'll make sure that the History Options are set so Allow Non-Linear History is off. And we already saw that the color settings are set to North America General Purpose 2. So we are ready to run this script. Let's go ahead and try it out. Ooh, ooh, let's set the foreground and background colors to different colors here. Something really wildly, hideously ugly, like red with magenta.
As I'm recording this series for you, that's the most recent version of the program. If you have 9.0, you should go online, you should go to the Adobe website, and check out the update. But Photoshop should do that automatically, it should check for updates automatically, but you really owe it to yourself to stay on top of those updates, because they're generally bug fixes and they take care of bugs that you may be experiencing. The program is installed in the directory blah blah blah. The amount of memory available to Photoshop CS2 is 964 megabytes.
(chuckles) See, that's why I did that, because otherwise it's, what, I don't even know where I am. (chuckles) There's no commas, so I can't, it happens to be 1,010,869,571 bytes. Well, you know what? (chuckles) Bite me. That doesn't help me out at all. 964 megabytes, though, now, that's different. That helps me out a lot. You currently have one document open. Why, thank you very much for that message. Now let's check out our preference settings.
(gasps) Turned off Export Clipboard. It turned on Zoom Resizes Window. It turned off Use Shift Key for Tool Switch. It set Image Interpolation to Bicubic Sharper. It turned off this darn function, set it to Never. Let's go to the fifth panel. Rulers are pixels, that so rocks. Go over here, let's check out History Options. Non-Linear History is turned on, coolio. Click OK, and let's see. Finally, Control + Shift + K, or Command + Shift + K on the Mac, and it's set my color settings to Best workflow.