Sampling the top left pixel is an interesting idea.
The other aspect of JPEGs that would make this tricky is that the color tends to be highly variable. Think of a photo, for example. The compression used in JPEGs works against the integrity of flat color—so even if you were dealing with a border around a photo, there'd be color variability where the border meets the image. You might have an easier time if you were working with an indexed color format like GIF or PNG-8.
You can, incidentally, use Fireworks' History panel to create command scripts. So if you can perform a task in Fireworks, there's a chance you can convert it into a script from there. Once it's a script, it can be integrated into a batch process. That said, not all actions performed in Fireworks can be recorded properly, so extra work is often required to make a script actually useful and workable.
Hey... solved it! Changed the background color in almost 2,000 jpegs. Heres how:
Photoshop CS4, first define a color in an AXT file:
Open test image, image, adjustments, replace color. use eye dropper to sample the background color, bring hue, saturation, and lightness bars all the way to the right (background color now turnd white), click save (save the definition AXT file, you will need to reference it later).
Now create a new action called "replace color", have test image open (with original background that you want to change), start record and do this to record the action:
Image, adjustments, replace color. Click load and select the AXT file, click load (the background color now turns white with the loaded AXT definition). Click ok. save file. Stop record action.
Now run a batch command and use that action you just recorded: File, automate, batch, select your new action in the play section, select the folder of files to process and the destination... click ok to run the batch.
I changed the "background" color in 2,000 estore product images of various sizes (thumbnail, medium, and large sizes) in about 15 minutes. Wow! I knew there had to be a way.
Hope it helps lots of people, 'cause it sure is a common need.
Thanks, I hope it is helpful to others as well. I build sites for small business, and my graphics guy's jaw dropped when I walked him through the steps (he had always done similar functions mannually since there is no "button" to do this entire process). I figure that at a minimum of 5 minutes per image (I actually had 1,944 images), the work would equal 162 hours.
This process did it in minutes.
Thanks again for jumping in to help!