Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 使用透明背景将gif转换为jpg_Powershell_Image Conversion - Fatal编程技术网

Powershell 使用透明背景将gif转换为jpg

Powershell 使用透明背景将gif转换为jpg,powershell,image-conversion,Powershell,Image Conversion,在每个人链接之前,我必须说我已经在使用这个线程的解决方案了 我正在将大量的静态gif文件转换为jpg。然而,其中一些有透明的背景,在那里我得到黑色背景,这是不可接受的 我试图使用MakeTransparent(),但我不知道如何使用它,或者它不起作用 # first try $image.MakeTransparent("white") # second try $col = "#FFFFFF" $image.MakeTransparent([System.Drawing.ColorTrans

在每个人链接之前,我必须说我已经在使用这个线程的解决方案了

我正在将大量的静态gif文件转换为jpg。然而,其中一些有透明的背景,在那里我得到黑色背景,这是不可接受的

我试图使用
MakeTransparent()
,但我不知道如何使用它,或者它不起作用

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

# second try
$col = "#FFFFFF"
$image.MakeTransparent([System.Drawing.ColorTranslator]::FromHtml($col))
两者都在powershell中运行,没有错误,但都生成黑色背景

我还找到了
Bitmap.Clear(Color.White)
Bitmap.SetTransparencyKey(Color.White)
,但当我尝试运行代码时,收到一个错误

方法调用失败,因为[System.Drawing.Bitmap]不包含名为“Clear”的方法

同样适用于
SetTransparenctKey


还有其他简单的功能可以使透明背景变白吗?

JPG不能支持透明背景。它使用RGB颜色空间。使用另一种格式,如PNG。

JPG不能支持透明背景。它使用RGB颜色空间。使用另一种格式,如PNG。

这就是为什么我希望背景为白色,使用PNG最容易,但我必须制作JPEG。这就是为什么我希望背景为白色,使用PNG最容易,但我必须制作JPEG。