Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
I have the following command to convert a pdf file to a png with transparency...
The PDF file (CMYK format) is a white background with a black image so I want to take everything that is White and make it transparency while leaving anything that is black alone.
Can anyone tell me if this is the correct way of doing this or if there is a better way to do it?
Also when it does get converted the edges of the black area are jagged meaning there are still some white areas that remain on the file and it just looks really bad. Anyone have a solution to this or a better way of doing this.
Transparency will be either on or off (no partial) with the command you have. So you will lose any antialiasiing.
IM does not process CMYK very well. So you would be better to convert to sRGB by adding -colorspace sRGB right after the convert and before the pdf read.
You use of -fuzz 900 assumes that you are using 16-bit (Q16) IM compile. A value of 900 is rather small in comparison to 65535. I generally prefer to use percent with -fuzz.
Generally, -channel rgba is not needed with -transparent. But it should not hurt to include it.
You have not said what kind of pdf you have. Is it in color or grayscale or binary black/white?
What version of IM are you using and what platform?
It might be helpful if you provide a link to your pdf so other can see what you have and test with it.
Ill try to get files to you soon and all that you asked for
But as far as fuzz value what would you recommend for percentage wise? I tried 65% and it looks pretty good on a larger png file but still bad on a smaller one. Does it depend on the dimensions?
It depends on the image itself and not the dimensions.
We probably can help you with creating a mask from the thresholded image and then blurring it to antialias the edges and then use the mask as a transparency channel instead of the binary one. But it would help to look at your images.
The process would be something like
convert image \( -clone 0 -fuzz XX% -transparent white -blur 0x1 \) -alpha off -compose copy_opacity -composite resultimage
The -blur 0x1 may have to be adjusted depending upon your image.
The above is unix notation. If on windows remove the \ before the two parens and use %% in place of %.