Page 1 of 2
Create BMP image with transparent background
Posted: 2011-05-03T05:48:00-07:00
by rakeshkumar.nampally
Hi All,
I am new bie to Image Magick, trying to create bitmap image with transparent background using Image Magick command line tools.
Command:
Code: Select all
convert.exe -size 500x500 -background none -font Verdana -fill white -gravity center caption:"Some text here" -shade font.bmp
Using above command by default it is preserving black as its background image. I tried many ways to remove the background color from the image but was not successful.
Same command is working with other file formats like gif, png, etc....
Please help if anybody has done or gone through this earlier
Regards,
Rakesh.
Re: Create BMP image with transparent background
Posted: 2011-05-03T10:24:58-07:00
by fmw42
You don't say what version of IM you are using nor platform, though I suspect Windows.
Anyway, -shade needs arguments. So this works fine for me on IM 6.6.9.7 Q16 Mac OSX Tiger.
convert -size 500x500 -background none -font Verdana -fill white -gravity center \
caption:"Some text here" -shade 135x45 font.bmp
However, my browsers (safari an firefox) will not display the transparency from a bmp file, though other viewers show the transparency fine. If you use png for the output, then the browsers show the transparency fine.
Re: Create BMP image with transparent background
Posted: 2011-05-03T18:59:25-07:00
by rakeshkumar.nampally
Thank you for reply Fred!!!
I am working on Windows XP OS and using IM version 6.6 for windows.
I have used the shade already sorry to not to mention values in my post. It shades the background image right?? But my text is not appearing in the expected color when we use shade it always give a watermark text color. please correct me if i am wrong anywhere.
After generating bmp image with below command when view it through Windows Picture viewer or IE browser, it shows gray background
convert -size 500x500 -background none -font Verdana -fill red -gravity center \
caption:"Some text here" -shade 135x45 font.bmp
If i remove shade from the above command text will be in red color but background will be in black.
please suggest. thanks a ton
Re: Create BMP image with transparent background
Posted: 2011-05-03T19:32:52-07:00
by fmw42
As I suggested before, it is likely that your viewers and browser do not show transparency in bmp files. Try using png and see if looks correct. Or try displaying your bmp with Imagemagick display or whatever is used under Windows.
Using -shade will convert your red text to gray. But if displayed in IM, I see the transparency, but it does not show in any other viewer or browser for me. see
http://www.imagemagick.org/Usage/transform/#shade. Did you really want -shade or perhaps you really wanted -shadow? see
http://www.imagemagick.org/Usage/blur/#shadow and
http://www.imagemagick.org/Usage/fonts/#soft_shadow
identify -verbose font.bmp
Image: font.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 500x500+0+0
Resolution: 28.34x28.34
Print size: 17.6429x17.6429
Units: PixelsPerCentimeter
Type: GrayscaleMatte
Base type: GrayscaleMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
gray: 8-bit
alpha: 8-bit
Channel statistics:
Gray:
min: 94 (0.368627)
max: 236 (0.92549)
mean: 179.415 (0.703587)
standard deviation: 10.4669 (0.0410465)
kurtosis: 32.5612
skewness: -3.73536
Alpha:
min: 0 (0)
max: 255 (1)
mean: 28.8786 (0.113249)
standard deviation: 79.9578 (0.31356)
kurtosis: 3.99565
skewness: -2.44028
Re: Create BMP image with transparent background
Posted: 2011-05-03T22:05:36-07:00
by rakeshkumar.nampally
When i open it with Image Magick Display it is showing transparent background but when i try to place it on some other image or video it is still showing the black color background. Any Ideas why so??
Thanks a lot
Rakesh.
Re: Create BMP image with transparent background
Posted: 2011-05-04T06:47:44-07:00
by rakeshkumar.nampally
Hi Fred,
I was able to generate the transparent background bitmap image using GIMP, when i placed it over another image or video background is completely transparent.
Please find the characteristics of the image:
Image: 123456789.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 343x512+0+0
Resolution: 28.35x28.35
Print size: 12.0988x18.06
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 20 (0.0784314)
max: 255 (1)
mean: 180.735 (0.708766)
standard deviation: 43.1393 (0.169174)
kurtosis: 2.90705
skewness: -1.86381
Green:
min: 10 (0.0392157)
max: 244 (0.956863)
mean: 172.018 (0.674582)
standard deviation: 44.0135 (0.172602)
kurtosis: 0.880937
skewness: -1.39622
Blue:
min: 0 (0)
max: 255 (1)
mean: 131.101 (0.514121)
standard deviation: 87.1162 (0.341632)
kurtosis: -1.55649
skewness: -0.553178
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 161.285 (0.63249)
standard deviation: 61.6101 (0.241608)
kurtosis: 1.47901
skewness: -1.66704
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 343x512+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2011-05-04T19:14:51+06:00
date:modify: 2011-05-04T10:08:05+06:00
signature: f8a5ac8610f04f8e56728ab00c971ca65ed984884c21f49a4e5eb82c4f8abb86
Artifacts:
verbose: true
Tainted: False
Filesize: 703KBB
Number pixels: 176KB
Pixels per second: 10.98MB
User time: 0.016u
Elapsed time: 0:01.015
Version: ImageMagick 6.6.9-4 2011-04-01 Q16
http://www.imagemagick.org
Please help me if we can achieve same through Image Magick
Thanks a ton
Rakesh.
Re: Create BMP image with transparent background
Posted: 2011-05-04T10:00:16-07:00
by fmw42
The image above has no alpha channel.
Type: TrueColor
If it did, it would be truecolormatte.
So I am not sure what to tell you. Let me see if I can overlay your image on some other. I will get back.
Re: Create BMP image with transparent background
Posted: 2011-05-04T10:08:06-07:00
by fmw42
This works just fine for me.
convert -size 500x500 -background none -font Verdana -fill white -gravity center caption:"Some text here" -shade 135x45 font.bmp
convert logo: font.bmp -gravity center -composite logo_font.bmp
The font.bmp is overlayed on the logo: image in the center with the logo showing under the transparent areas of font.bmp
IM 6.6.9.7 Q16 Mac OSX Tiger
Re: Create BMP image with transparent background
Posted: 2011-05-05T04:32:56-07:00
by rakeshkumar.nampally
Thank you Fred!! with the example you have given i was able to see the transparent background of first image.
But what i exactly need is to have complete transparent background and only text displayed.
In provided example case we were able to the logo at the background of the text, but there i want it to be transparent.
I tried this way but still I white background and text over it for the image:
convert -size 400x100 -background none -font Verdana -fill red -gravity center caption:"Copyright ©" font.bmp
convert -size 400x100 pattern:GRAY100 font.bmp -gravity center -fill "rgba(0,0,0,0)" -composite logo_font_graypattern.bmp
Please help me if we can have transparent background of the overall (in this case on the logo_font_graypattern.bmp) image.
Regards,
Rakesh.
Re: Create BMP image with transparent background
Posted: 2011-05-05T09:51:11-07:00
by fmw42
convert -size 400x100 pattern:GRAY100 font.bmp -gravity center -fill "rgba(0,0,0,0)" -composite logo_font_graypattern.bmp
Sorry I don't understand the purpose of this command.
Can you explain how you want the final image to look? You are overlaying your transparent font image onto a white background (gray100=white). If you are trying to make that white background transparent, then you don't need this command at all. Your first command produces a text with a transparent background as font.bmp.
convert -size 400x100 -background none -font Verdana -fill red -gravity center caption:"Copyright ©" font.bmp
If you want to overlay the image onto gray background, then try this:
convert -size 400x100 xc:gray -background none -font Verdana -fill red -gravity center caption:"Copyright ©" -gravity center -composite font_gray.png
Re: Create BMP image with transparent background
Posted: 2011-05-08T07:00:08-07:00
by rakeshkumar.nampally
I exactly want to create an image 32 bit depth bitmap image which has transparent background and some name on it. when we overlay the same image on video it should only display name what ever we write on the image, except that it should not display background of the text.
Please share if this can be possible.
Thanx alot Fred!!
Regards
Rakesh
Re: Create BMP image with transparent background
Posted: 2011-05-08T11:13:16-07:00
by fmw42
The example above, repeated here does just that on a single image. Try it for yourself:
convert -size 500x500 -background none -font Verdana -fill white -gravity center caption:"Some text here" -shade 135x45 font.bmp
convert logo: font.bmp -gravity center -composite logo_font.bmp
If you want to overlay the transparent text image on an animation or video then you need to study:
http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_mods/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/video/
In particular see the animations at
http://www.imagemagick.org/Usage/anim_mods/#compose
Re: Create BMP image with transparent background
Posted: 2011-05-09T21:45:01-07:00
by rakeshkumar.nampally
Thank you Fred.
To overlay image on video we are using another product, all we need is to provide bitmap image to that product. So when I try to create bitmap image with some text by default background color is getting preserved when overlaid on the video.
Regards
Rakesh.
Re: Create BMP image with transparent background
Posted: 2011-05-10T10:07:26-07:00
by fmw42
The problem appears to be with your other tool and not with IM. My example above shows that IM does create the correct image and it can be properly overlaid on top of another image. My only suggestion would be to try PNG or GIF and see if those work better than BMP.
Re: Create BMP image with transparent background
Posted: 2011-05-10T22:38:48-07:00
by rakeshkumar.nampally
I wish the tool that overlays image on video supports GIF or PNG, it only supports 32 bit depth bitmap images.
But when i create image with GIMP tool and use Fuzzy tool to select and add mask layer, background of image is transparent when we overlay the same image.