Mobile app version of vmapp.org
Login or Join
Welton168

: ImageMagick - How to convert png image background to transparent leaving only text? This question is asking for an ImageMagick method not Photoshop. I'm hoping someone will be able to tell me

@Welton168

Posted in: #Background #Color #Imagemagick #Png

This question is asking for an ImageMagick method not Photoshop.

I'm hoping someone will be able to tell me what to type in cmd to perform the following operation:

I have an image file with a black/grey background. There is bold blue text on top of that background. So basically, I'm looking to convert anything that isn't part of the text (i.e the backround) to transparent in the PNG. Here is my image:



I would also like to do this with an identical image where the text is coloured red. The point is so I will end up with images that only contain the text against a transparent background, so that I can place them on new background. I have tried convert image.png -transparent black newImage.png in the ImageMagick cmd tool, but to no avail. I think if I new how to specify the range of black and grey rather than just 'black', I might have better luck, but the command line tool is overwhelming as I'm not a graphics person. No clue what I'm doing...

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton168

3 Comments

Sorted by latest first Latest Oldest Best

 

@Shelley591

EDIT: Sorry, I missed the cmd line part, and really have no idea, so leaving this for other users or if the OP changes his mind, but please mods delete if unsuitable.

The easy way in Photoshop (looks like a lot of step, but it's really easy and fast once you know it):


start by duplicating the layer. Do it twice just in case (so ctrl+j twice)
Right under the active layer, add a layer and cover it with a very different and distinctive color. I usually use a soft pink for this. This layer is just so you can easily see what you're doing.
Now, back to your top layer go to Image --> Adjustments --> Curves or simply ctrl+m
Adjust curves until colors get really different and almost plain. This means you need to go extreme. Here are my settings:

Now select the Magic Eraser Tool. Give it a high Tolerance value. I chose 60 for your image, and also unchecked the contiguous box (this is really important). Apply it on the black area. You'll end with something like this:





Now, simply ctrl+click on the active layer so you select its contents. Disable the pink layer and select the copy you originally made (or your background) and hit ctrl+j
The above will create a new layer with the original colors. Disable all other layers and you're done!


Final result

10% popularity Vote Up Vote Down


 

@Dunderdale640

You basically want to do a chroma key – a green screen or, in this case, blue screen – but in reverse. Knocking out everything that isn't blue.

The easiest way to do that in Photoshop is with Select->Color Range as scottperezfox said. Select all the blues/cyans, invert it, and delete the background.

You can use after effects by making each of your images a frame of a video. If you have a series of images with sequential names, you can import them directly. Then use keylight to create the key and invert the alpha channel.

As far as using something like imagemagick, I found this on stackoverflow.

10% popularity Vote Up Vote Down


 

@Ann6370331

I can only suggest the "long" way, which involves some editing in Photoshop (or similar).

In this case, the fastest way would be to use Select > Color Range... and then choosing the Blues and fiddling with the settings. This will scoop up only the Blues and not the background.

The longer way would simply be to retrace this text as a new path. It'll take longer, but in the end you'll have a hi-quality vector version.

When that's done, save out as PNG with a transparent background. Unfortunately, I can't think of a way to simple convert the background to transparent. Being a designer, I'm really not familiar with command line editing of images. Outside of simple solid colours, I can't see how it's even possible.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme