Page 1 of 1

Transparent Background for Images with Text

Posted: 2019-02-12T22:57:55-07:00
by joshiishan
I have thousands of images with equations and text with white background. I need to make the white background transparent.

The command I tried as always was:

Code: Select all

convert _VP_EQN_61.GIF.png -fuzz 10% -transparent white _VP_EQN_61-converted.png
This command works perfectly with images without any text but when it comes to images with text, the edges/borders of the text becomes, for the lack of a word, unclear.
Example:
Original Image: Image
Result Image: Image

P.S. Please open the image in new tab with any dark background to see the issue clearly. Apologies for not being able to do it here.

I need some help creating images with transparent background with losing the text clarity/quality.

Re: Transparent Background for Images with Text

Posted: 2019-02-13T01:00:12-07:00
by fmw42
try

Code: Select all

convert VP-EQN-61-GIF.png -negate -threshold 0 -negate -alpha copy -channel a -negate +channel result.png

Re: Transparent Background for Images with Text

Posted: 2019-02-13T05:29:40-07:00
by snibgo
An alternative method results in black text and anti-aliased alpha:

Code: Select all

convert VP-EQN-61-GIF.png -negate -alpha copy -channel RGB -evaluate set 0 +channel out.png

Re: Transparent Background for Images with Text

Posted: 2019-02-14T01:03:01-07:00
by joshiishan
fmw42 wrote: 2019-02-13T01:00:12-07:00 try

Code: Select all

convert VP-EQN-61-GIF.png -negate -threshold 0 -negate -alpha copy -channel a -negate +channel result.png
Thanks for your response. It gave me an image with thicker text (like bold) but the text border was not smooth. Attaching the resulting image.
Image.

It is looking good or fonts which are a bit thicker but not on the thin fonts.

Regards,
Ishan

Re: Transparent Background for Images with Text

Posted: 2019-02-14T01:05:13-07:00
by joshiishan
snibgo wrote: 2019-02-13T05:29:40-07:00 An alternative method results in black text and anti-aliased alpha:

Code: Select all

convert VP-EQN-61-GIF.png -negate -alpha copy -channel RGB -evaluate set 0 +channel out.png
This worked for all my files!

Thanks a lot!