How to give background to the png at a particular area

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nasaa1
Posts: 3
Joined: 2013-06-11T02:03:16-07:00
Authentication code: 6789

How to give background to the png at a particular area

Post by nasaa1 »

Hi,

I have this image - Image http://postimg.org/image/xmlwkmec5/f5325cd6/

I was wondering if I can hide the transparency or give a white background to only selected area and not the whole image.

Any idea will be highly appreciated.

Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to give background to the png at a particular area

Post by fmw42 »

The image that is there to download is jpg and thus has no transparency.

Nevertheless, if you just want to change any full transparency to some color, say white, then just flatten it against a white background

convert yourimage -background white -flatten result

If that is not what what you want please explain in more detail. Also identify your IM version and platform.
nasaa1
Posts: 3
Joined: 2013-06-11T02:03:16-07:00
Authentication code: 6789

Re: How to give background to the png at a particular area

Post by nasaa1 »

Apologies for the wrong image

Image

I want to get rid of the transparency from certain part of image and not the whole image. So in this case I would like to get rid of transparency from the "RADIO TIMES" Text
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to give background to the png at a particular area

Post by fmw42 »

Extract the alpha channel

convert flatten_canvas2.png -alpha extract 1tmp1.png

Then draw a white filled polygon over the area you want to make opaque in the alpha image.

see
http://www.imagemagick.org/Usage/draw/#primitives

Then replace the alpha channel in the original image with the new alpha channel image

convert flatten_canvas2.png newalphaimage.png -alpha off -compose copy_opacity -composite result.png
Post Reply