You are browsing the "Programming" archives.
10 Photoshop Selection Tips
Sunday, October 7th, 2007 at 8:50 PM
Select a Layer Outline
Command-Click a layer thumbnail in the Layers palette to load a selection of its outline, including any anti-aliased (non-jaggy) edges. If your layer has an inherent opacity set (for example, if you opened a partially transparent PNG image), the opacity difference is included in the selection. Normal opacities set in the Layers palette, however, do not affect the selection.
Use Multiple Selections
Once a selection is made, there are a number of operations you can perform to modify your selection. Holding Shift and making an additional selection will add to your current selection, and Option will remove from it. Holding both Shift and Option will do something unique: wherever your two selections intersect will become the new selection.
Combine Layer Outlines
Using the first Command-click thumbnail hint with Shift, Option, or Shift+Option modifier keys, you can add, remove, or intersect selections using outlines of other layers. Your cursor will show +, -, or x to indicate which type of operation will be performed, respectively.
Move Selection While Dragging
While in the middle of dragging a selection, you can hold down the spacebar to move around the origin of the selection. This is extremely useful if you find that your selection is a bit off — Instead of re-making a new selection from scratch, you can make adjustments “on the fly.” When the spacebar is released, the selection seamlessly drops back into the default “grow” mode, using the new origin as the starting point.
Start at the Center
Hold down Option after starting a selection to expand from the middle, causing the outline to grow symmetrically in each cardinal direction. Add the Shift key into the mix Shift to maintain a square shaped ratio.
Fixed Ratios and Sizes
Using the selection tool options, you can set a fixed ratio or specific size, both of which are great for slicing out content with a pre-determined size, like that of a computer wallpaper. Using the ratio, you can select a portion of an image that would fit on your desktop. Once you have the portion selected, you can scale it down to the native resolution of your display, being sure that it will scale proportionally to the correct size.
Quick Mask Mode
By flipping into Quick Mask Mode, you can use paintbrush tools to “paint” the beginnings of a selection. When you leave Quick Mask Mode, the painted area becomes a selection which you can use right away or modify further.
Transform!
Use the Select->Transform Selection command to distort the current selection. Note that this applies to just the selection outline, not the content within it. (To change the content, do Edit->Transform->transform type).
Selection Paste Target
By making a selection and then pasting content into it, you can target exactly where the pasted content will land. Without a selection, pasted content simply gets dumped in the middle of the document.
Save Selections with the PSD File
Once you have your beautiful selection made and ready to use, you might consider saving for future use if it was particularly complicated to make, or if it’s a handy, reusable shape. Photoshop provides two simple commands for saving and loading selections. Choose Select->Save Selection to commit your selection to a given name. Retrieving it is as simple as picking the Select->Load Selection command, and choosing the name you saved the selection under earlier. Best of all, these named selections are included in the file, meaning you can save and re-open the document, and reload selections at a later date.
This entry was posted
on Sunday, October 7th, 2007 at 8:50 pm and is filed under Programming, Tips.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
jQuery Spinner Plugin
Monday, May 7th, 2007 at 7:07 PM
In an earlier post, I put together a package of several spinner images for your Web 2.0 apps, however it was a bit lacking as far as scripting and programming goes. To make full use of the PNG “filmstrip” style spinners, you’ll need a bit of JavaScript to make them go.
If you use the exceptional jQuery JavaScript library to make your software shine, you’ll be able to easily load and run the PNG spinners with this little jquery.spinner.js plugin I put together. Included in the package is a simple HTML file detailing how to use the plugin, but the basics are as follows:
After including jquery.js (or jquery.pack.js) and jquery.spinner.js in your HTML head, set up an empty div and call the .spinner function with some simple parameters:
$(”#spinme”).spinner({ height: 48, width: 48, speed: 50, image: ’spotlight_spinner_big.png’ });
You can pass width, height, frame speed, and an image URL to set up the spinner, as well as call $.spinnerStop(); to halt the spinner.
While I’ve worked on a few jQuery plugins before, I’m not entirely sure all the programming conventions I’ve used are “correct” (like the global $.spinnerStop). That in mind, if you find any bugs or notice an issue, please let me know, and I’ll update the plugin as soon as possible. Get the plugin here.
Special thanks to the talented Rogie King for some last-minute fixes!
This entry was posted
on Monday, May 7th, 2007 at 7:07 pm and is filed under Programming.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Setting up MySQL 5 and PHP 5 under Mac OS X (Tiger)
Sunday, April 22nd, 2007 at 2:39 PM
While setting up MySQL 5 and PHP 5 today, I documented the steps I took to get it all running under Tiger. Here’s the basic rundown if you’d like to move to these new versions as well.
Downloads
Install Xcode
Installation of Apple’s Xcode Developer Tools is straightforward — just install the .pkg file inside the .dmg if you downloaded it, or run the .pkg from the discs that came with your computer.
Install MySQL 5
Setting up MySQL is just as easy as installing Xcode, as the developers have kindly put together a .pkg installer. You could always compile it yourself if you have the need. Also included in the .dmg are a StartupItem and Preference Pane, both of which I find handy (although StartupItems are a bit out-of-date, and should probably be replaced with a launchd item).
Install PHP 5
Unpack PHP’s .tar.gz file with your favorite decompression utility, and open a Terminal window. Type cd, followed by a space, then drop the uncompressed php-5.2.1 folder right into the Terminal window and hit Return to change directory to the PHP files.
Type ./configure –with-mysql=/usr/local/mysql –with-apxs=/usr/sbin/apxs to configure the PHP installation, noting the location where MySQL keeps its files (so PHP knows how to get to it in the future).
While PHP is configuring, in a new Terminal window, you should set the root password for MySQL.
Enter cd /usr/local/mysql/bin,
then ./mysqladmin -u root password ‘new-password’, where new-password is your chosen MySQL root password. Note that this has nothing to do with your computer’s “root” password, and is entirely separate.
Back at the PHP prompt, you’ll see “Thank you for using PHP.” when it’s done configuring. You can then enter make to compile PHP from the source code. This may take a while. When done, enter sudo make install to install the files to their predetermined locations.
Reconfigure Apache
You’re almost done, except that the Apache web server doesn’t know to handle .php files for PHP 5. PHP 4 comes preinstalled with Mac OS X, but PHP 5 changes your Apache config file to enable itself (to include its shared objects when Apache boots), which turns off PHP 4. In this state, .php files will be printed out to the web browser as text files instead of executed — that’s not good! You’ll have to tweak the config file and reboot Apache to make it all go again. If you have TextMate’s command-line utility installed, these next steps are quite easy.
Enter sudo mate /etc/httpd/httpd.conf (or sudo pico /etc/httpd/httpd.conf without TextMate) in the Terminal to edit the Apache config file. Find <ifmodule mod_php4.c> and change that 4 to a 5, as we’re now using mod_php5.c.
You’ll also want Apache to recognize index.php as a Directory Index file, so hunt down DirectoryIndex index.html and add a space, then index.php to the list, so it looks like DirectoryIndex index.html index.php when done.
At this point you can save and exit if you prefer, but I like to make one last change so I don’t have to dig to /Library/WebServer/Documents every time I want to edit a file I’m working on. In the root of your hard drive, create a folder called WebServer, and then jump back to TextMate (or the Terminal window) where you’re editing the Apache config file. Find the line DocumentRoot “/Library/WebServer/Documents” and change it to DocumentRoot “/WebServer”. After making this change, also change the location a few lines down: <directory “/Library/WebServer/Documents”> to <directory “/WebServer”>. Finally, save and exit.
Back at the Terminal prompt, enter sudo apachectl graceful to reboot Apache and let everything fly. I hope that helps some people setting up a PHP coding environment out there! A final note: watch out for the “smart quotes” Wordpress likes to insert — they may cause copy-and-pastes to produce failures in the Apache config file.
This entry was posted
on Sunday, April 22nd, 2007 at 2:39 pm and is filed under Mac, Programming, Tips.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Duplicatr 1.1
Monday, October 23rd, 2006 at 9:07 PM

It’s been quite some time since I’ve worked on Duplicatr, my Flickr metadata mirroring project, so here’s an significant update for those that are making use of the code. This version adds a number of highly requested features:
- Mirroring of 500+ photos
- Fetching information about photos added since the last run
- Tag-based filtering
- Simplified installation and execution
Download
Duplicatr version 1.1 can be downloaded here, and a link to the most current version will always stay in the sidebar at left.
Installation
1. After downloading the package, unzip it using your preferred utility (I recommend The Unarchiver for Mac OS X, and 7-Zip for Windows — both are free) and save the files in a convenient directory in your web folder.
2. Open duplicatr_config.php with an available text editor and fill in the details for your MySQL database and credentials. Note that you must already have a database created, which can be done with any number of utilities or directly from the command line using the mysqladmin program that comes prepackaged with MySQL.
3. Also edit index.php and fill in your Flickr ID (or email address) and desired tags. Following the example in the code, you can add as many tags as you like. This may be useful if you intend to have only photos with a specific tag appear or be searchable on your site. If you don’t need this feature, they are commented out by default and won’t be used for filtering.
4. With the database ready and Duplicatr in an accessible place, visit www.your-domain.com/duplicatr/install.php, or whatever the path to install.php may end up being in your case. The install script will create the necessary tables and inform you of its results. Once completed, you can delete the install.php and go directly to index.php to kick off the duplicating!
This entry was posted
on Monday, October 23rd, 2006 at 9:07 pm and is filed under Programming.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.