in reply to Replace certain color in jpeg

Could you do something using perl and gimp? image::magic can do a lot, but i don't think it's going to help you.
1. Background
One of the wonderful features of GIMP is that it all its functionality may be accessed through scripting. So far most of the script programming for Gimp has been done through Scheme through Script-Fu. Unfortunately the Scheme environment Gimp provides is very primitive, e.g. without any reasonable error handling. Furthermore, must users are not familiar with scheme as a language. Some users may therefore prefer to write scripts for the Gimp in Perl.

A Tutorial for Perl Gimp Users