"David Mathog" on  wrote...
| Greetings,
| 
| Sorry to bother you with this but you clearly know your way around
| ImageMagick.  I just read through this page:
| 
|   http://www.cit.gu.edu.au/~anthony/graphics/imagick6/color/
| 
| but still couldn't find what I was after.  We often have pictures
| where the background is black but needs to be changed to white
| for printing (or vice versa, for instance, for publication).  Is
| there a simple command more or less like this:
| 
| convert   -from (255,255,255) -to (0,0,0) blah.jpg changed.jpg
| 
Note you sould read in images before you modify them :-)
The above sequence you give will work, but may have problems later as
you add more operations.  See  The start of IM Examples -- Basics
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/basics/

As for you problem...
| It looks like it should be possible by combining -opaque and -fill
| but I've not yet hit the right syntax.
| 
You were on the right track

   convert input.jpg   -fill to_color  -opaque  from_color    output.jpg

However you have two other problems,  Image Format, and Background
Masking. That is what you actually want to do, rather than how you are
doing it.


Summery of Background Color Replacement (to become its own page)...

First as you input image is JPG, colors are typically not exact the the
same as when you saved the image...  JPG is a lossy format, avoid it
for intermediate work...
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/formats/#jpg

This problem is mentioned thoughout the examples and in mail lists and
forums again, and agian.

The solution is to 'fuzzy match' the colors a little

   convert input.jpg -fuzz 5% -fill to_color -opaque from_color output.jpg

See the BOTTOM of the color page you were on...
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/color/#recolor
This was updated yesterday, in prepration to adding of actual examples.

However even this has problems, as shown by an excelent example page
by Pasha Sadri <[EMAIL PROTECTED]>....
   http://www.polyvore.com/images.html


Something like this page (with permission) will be merged into IM Examples
at the point where it is talked about... Masking images for background
replacement...  Channels and Masks...

  Re-adding Transparency to an Image
    http://www.cit.gu.edu.au/~anthony/graphics/imagick6/channels/#mask_creation


One 'better' solution, which is still in its formulation stage, is using
a gradient color replacement scheme, as detailed by Rick Mabry
<[EMAIL PROTECTED]>.

In Summary, he is replacing colors along a specific gradient between two
colors, with some fuzzy matching to locate colors close to the gradient
line.

See example results in
   http://www.lsus.edu/sc/math/rmabry/imagemagick/multireplace/

The final method will probably require some limit masking (from previous
techniques), to ensure only the background is recolored.

As you can see background replacement is not simple, and has lots of
problems.  Things are happening, but I have not had the time to convert
my notes (above) into a comprehensive practical examples page.  Yet.


Eamil CC'ed to IM mailing list, Pasha Sadri and Rick Mabry, for others
input and feedback to this problem and hopefully prevoke further
development.


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
      `` Watch Out!  He's got a dragon! ''
                               -- Robert Asprin - "Another Fine Myth"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to