15

I want to get a transparent background or no background for my images. I tried the '-background none' option and also the 'transparent' option, but the background image remains white. How can I achieve this?

Please suggest.

Manisha Dugar
  • 189
  • 1
  • 1
  • 5
  • does your image have a white background by any chance? – TimCodes.NET Mar 08 '11 at 08:28
  • Yes, it shows a white background even though I create none. – Manisha Dugar Mar 08 '11 at 12:19
  • Probably need more info. Are you asking how to create a transparent GIF or PNG? Or how to make images have transparency in some development or HTML environment? Or? – gwideman Mar 08 '11 at 08:25
  • I have a png image with pure white background. My aim is to superimpose this image(without any background) onto another image. The problem I am facing is that the white background is also superimposed onto the image while doing so. – Manisha Dugar Mar 08 '11 at 12:18
  • 1
    https://stackoverflow.com/q/11509894 – caw Apr 09 '19 at 21:18

2 Answers2

20

If you are using Imagemagik then the command is:

convert input.gif -transparent white output.gif  

However, it will only work with a pure white background and not a shade of white. There are alternative and easier ways to do this with IrfanView or The Gimp or Photoshop (more on that below). This article mentions that you may be using convert.exe that comes with Windows rather than ImageMagicks Convert.exe in which case you should use the full path for Convert.exe. http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=10665

If you are trying to achieve this from CSS then you misunderstand the CSS property. The css property 'background' refers to an html elements background color. I.e. <p> <div> <body> whatever. more here http://www.w3schools.com/css/css_background.asp

If you are referring to the image opacity property, that refers to how "see-through" an image should be. more here: http://www.w3schools.com/Css/css_image_transparency.asp

The only way to get a transparent background in an image is to make the background of the image transparent using either the PNG (preferred) or GIF formats. For this you can use IrfanView and save a picture as PNG, select the "save transparency" property and select the color from the image you want to be transparent or you can use Photoshop or The Gimp do the same. Example for IrfanView here http://llizard.etherwork.net/cwc/transp_irfanview.html

The Gimp example here http://aplawrence.com/Linux/crousegif.html

Andhi Irawan
  • 456
  • 8
  • 15
Ali
  • 12,354
  • 9
  • 54
  • 83
-1

whats the format of your images? Try using png format

Swastik
  • 2,415
  • 2
  • 31
  • 61
  • I am using png format.Even tried creating some basic shapes in imagemagick, but a white circum-rectangle is always created though I set the background to none. – Manisha Dugar Mar 08 '11 at 12:31