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:

enter image description here

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...


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.

| improve this answer | |

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.

| improve this answer | |

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):

  1. start by duplicating the layer. Do it twice just in case (so ctrl+j twice)
  2. 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.
  3. Now, back to your top layer go to Image --> Adjustments --> Curves or simply ctrl+m
  4. Adjust curves until colors get really different and almost plain. This means you need to go extreme. Here are my settings: enter image description here

  5. 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:

enter image description here

  1. 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
  2. The above will create a new layer with the original colors. Disable all other layers and you're done!

Final result

enter image description here

| improve this answer | |
  • 1
    Hi Devin, you've fallen into the trap others, including myself, have. This question is asking about ImageMagik and NOT Photoshop. – Scott Sep 12 '17 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.