问题
I have an image that is black text with some gray and pale yellowish background. I basically want to keep the text as black as possible, and make the gray and yellow comparatively lighter...at the very least, turn yellow into a light gray. What's the most efficient way to do that in ImageMagick?
回答1:
Answering the title question: you can batch desaturate images with the options -colorspace Gray
OR -type Grayscale
OR -modulate 100,0
- reference here: the options don't work identically
Sample command:
mogrify -type Grayscale -path Output_Directory -type Grayscale *.jpg
Now as for your post... the complexity of the answer depends on the color transform involved. I'm no expert, but probably the easiest solution (based on what you seem to need) is to desaturate the image(s) and then increase contrast (and maybe brightness) using -brightness-contrast +5x25
(put in your own [brightness]x[contrast] values) or -normalize
(automatic) - reference here for adjusting contrast
Sample command:
mogrify -type Grayscale -path Output_Directory -type Grayscale -normalize *.jpg
回答2:
I'm not sure about the quality of ImageMagick's color transformations. Color is a complex and subjective area of research! I'd be a lot more comfident using an ICC profile that encoded the transformation you need, and applying it with lcms (which i've found is of the highest quality).
Now the problem becomes one of creating a transformation profile... i think Photoshop can save it's curves as profiles? maybe it's the other way around, and there are some profile tools that can use Photoshop curves as input...
来源:https://stackoverflow.com/questions/2655322/how-to-use-imagemagick-to-batch-desaturate-images