Please note that using
-fuzz XX -transparent is not a 'good' solution. All it does is replace any instance of pure or near pure white with transparency.
The problem with this is that images are rarely that simple. Usally text and drawings have edges that are a mix of the background and the object itself. that is they contain mixed colors to 'anti-alias' or make the displayed objects looks 'smoother' to the human eye.
As a result the image will have 'stair-cased edges', or 'white halo effects' around them.
However if you read the image in at a higher resolution, do the color replacement, and then re-sample the image back to the desired resolution (typically 72 or 90 dpi), then much of thos problems will be fixed by the resize operator 'cleaning up' the edges.
The better solution would be to somehow actually get IM to get the Ghostscript delegate to render the PDF file properly on transparency. Usually that is don by setting
-colorspace RGBA before 'reading' the PDF page.
Try reading the PDF like this....
Code: Select all
convert -background none -colorspace RGBA test.pdf test.png
Let us know how it goes.
This does not always work, as the PDF may actually draw white, such as in a diagram on the page, but it should work most of the time.