Page 1 of 1

transparent background - How! (solved!)

Posted: 2010-01-19T06:46:35-07:00
by Albireo
Hello!
My wish is to place an image on a transparent background.
(Background size 400x400 - image size maybe 300x400 or 400x300)

I have no problem to get an background, red, yellow or blue, but transparent......
The "transparent" background becomes usually black.

Sometimes I have succeeded with a transparent background,
but then I changed any parameter(size,path,images...), the background was black again.
If the change was restored the background remained black....

Have tested a number of variants of commands.
(here, an example (In Windows - one row):

Code: Select all

convert -define jpeg:size=400x400 hatching_orig.jpg -resize "400x400>" -background transparent -gravity center -extent 400x400 pad_extent.jpg
//Jan

Re: transparent background - How!

Posted: 2010-01-19T08:32:04-07:00
by Bonzo
jpg does not support transparency - use png

Re: transparent background - How!

Posted: 2010-01-19T09:02:55-07:00
by Albireo
Thanks very much, I had forgot it :-)

Re: transparent background - How! (solved!)

Posted: 2010-02-23T21:14:55-07:00
by imagecorpis
Hello,

I'm gonna use this thread since I have also a transparency related question.

I'm converting PNG files to 24-bit bitmaps, which as far as I know also don't support an alpha channel.
I would know to know if there is any way to map the alpha channel to a BMP image.

Let me explain better, I have a file.pgn texture with a transparent background. I want to convert this
to file.bmp (easy), and then have a second file_alpha.bmp file with the transparent background mapped as black
and white pixels. Is there a convert parameter to do that?

Re: transparent background - How! (solved!)

Posted: 2010-02-23T21:33:38-07:00
by fmw42
If I understand you correclty -- if your png file has transparency and you want to get a bmp file that is black/white representing only the transparency then try

convert image.png -alpha extract image_alpha.bmp

see http://www.imagemagick.org/Usage/basics/#alpha_extract


also see http://www.imagemagick.org/Usage/formats/#bmp as that says you can have 32-bit BMP (24-bit color and 8-bit transparency)

However, I cannot seem to get the transparency into the bmp by

convert logo2t.png -channel rgba -alpha on -depth 8 logo2t.bmp

Re: transparent background - How! (solved!)

Posted: 2010-02-24T07:11:18-07:00
by imagecorpis
That's exactly what I'm looking for, however using convert file.png -alpha extract file_alpha.png returns this:

convert: UnrecognizedAlphaChannelType 'extract'

I've tried both the 6.3.9 Windows static version as well as a later 6.5.9 Windows Static compiled from source.

I'm also interested in converting .PNGs with alpha to the 32-bit BMP with alpha format, that would be even better for my purposes.

Re: transparent background - How! (solved!)

Posted: 2010-02-24T10:53:03-07:00
by fmw42
imagecorpis wrote:That's exactly what I'm looking for, however using convert file.png -alpha extract file_alpha.png returns this:

convert: UnrecognizedAlphaChannelType 'extract'

I've tried both the 6.3.9 Windows static version as well as a later 6.5.9 Windows Static compiled from source.

I'm also interested in converting .PNGs with alpha to the 32-bit BMP with alpha format, that would be even better for my purposes.
-alpha extract is relatively new, but should be there fine for 6.5.9 (as that is what I use and it works). 6.3.9 is probably too old.

you can also get the alpha channel in older releases by

convert image.png -channel A -negate -separate image_alpha.png


about 32-bit bmp, see viewtopic.php?f=3&t=15643

Re: transparent background - How! (solved!)

Posted: 2010-02-24T13:37:29-07:00
by imagecorpis
Thanks! I was reading the documentation and also found that
"convert drawn.png -channel matte -separate +channel -negate mask_separate.png" also works for the same purpose.