0

Before everyone would link Convert all images to jpg I must say I am using solution from this thread already.

I am converting huge amount of static gif files to jpg. However some of them have transparent background and there I am getting black background which is not acceptable.

I was trying to use MakeTransparent() but I don't get how to use it or it doesn't work.

# first try
$image.MakeTransparent("white")

# second try
$col = "#FFFFFF"
$image.MakeTransparent([System.Drawing.ColorTranslator]::FromHtml($col))

Both run in powershell without errors but both generate black background.

I found also Bitmap.Clear(Color.White) and Bitmap.SetTransparencyKey(Color.White) but when I trying run code I receive an error

Method invocation failed because [System.Drawing.Bitmap] does not contain a method named 'Clear'.

Same for SetTransparenctKey.

Is there any other simple function to make transparent background white?

Community
  • 1
  • 1
tomipnh
  • 193
  • 3
  • 12

1 Answers1

3

JPG can’t support transparent background. It uses RGB color space. Use another format like PNG.

aston_zh
  • 6,543
  • 4
  • 20
  • 23
  • That's why I want make background white and using PNG would by easiest but I **have to** make jpegs. – tomipnh Mar 31 '16 at 06:38