LuckyImage is a Mac OS X service that replaces text with the first image that comes up for that text on Google Image Search.

It's intended for iChat lolz, but it'll work in (almost) any editable rich text field!

Before
After

How to install

  1. Download LuckyImage and unzip it.
  2. Place "LuckyImage.service" in ~/Library/Services. (If the Services folder doesn't exist yet, create it.)
  3. Log out of your Mac OS X user account, then log back in.

How to use

  1. Enter some text into an iChat window (don't send it yet), then select that text.
  2. Go to the iChat menu, then Services, and click Lucky Image.
  3. If you're lucky, you'll get an image back!

You can set a keyboard shortcut via System Preferences -> Keyboard & Mouse -> Keyboard Shortcuts. Click the + button, enter "Lucky Image" (without quotes) as the Menu Title, then choose a shortcut that's unlikely to be used for something else (for example, I use control-option-command L).

Advanced Configuration

LuckyImage currently has no UI, but you can still configure it in a few ways using Terminal (located in /Applications/Utilities).

Custom Search Parameters

You can set various Google Image Search options, such as SafeSearch or image size restrictions.

For example, entering this command into Terminal turns on strict SafeSearch (moderate SafeSearch is the default):

defaults write net.pozdena.LuckyImage CustomParameters "&safe=active"

Entering this command restricts the results to medium-sized images (which Google defines as all sizes between the "icon" and "xxlarge" sizes):

defaults write net.pozdena.LuckyImage CustomParameters "&imgsz=small|medium|large|xlarge"

And of course, you can specify multiple parameters like so:

defaults write net.pozdena.LuckyImage CustomParameters "&safe=active&imgsz=xxlarge"

Timeout

You can specify a custom timeout for retrieving an image (the default is 5 seconds). Here's an example command:

defaults write net.pozdena.LuckyImage Timeout 10

If LuckyImage can't retrieve the first image, it'll try one more time with the second image, meaning the worst possible delay is twice the timeout limit.