WideImage-转换后的PNG的透明区域应为白色 [英] WideImage - Transparent areas of converted PNG should be white

查看:72
本文介绍了WideImage-转换后的PNG的透明区域应为白色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当用户使用我的脚本上传照片时,WideImage都会将其转换为JPEG.但是,我只是注意到,如果我上传带有透明背景的PNG图片,则会将其改为黑色.

Whenever a user uploads a photo using my script, WideImage converts it to JPEG. However, I just noticed that if I upload a PNG picture, with a transparent background, it makes it black instead.

有什么办法代替这种白色吗?

Is there any way to make this white instead?

这是我保存图像的方式:

This is how i save the image:

$img->resizeDown('500', null)->saveToFile('annonce_billeder/'.$bnavn.'.jpeg', 70);

推荐答案

不是很直接.您将要阅读有关透明度如何存储在图片中的信息:这是一个普通的颜色值(任何颜色),已被特别标记为透明.

Not really directly. You wnt to read about how transparency is stored in pictures: it is an ordinary color value (any color) that has been marked especially as transparent.

因此,您实际尝试在示例图片中指定的颜色 很可能被编码为黑色,并且转换时透明度会丢失.

So most likely the color specified in the example pictures you try actually is coded as black and the transparency gets lost whilst converting.

您可能会尝试找出是否可以检测到传入图片中是否存在标记为透明的颜色,然后在转换图片之前将其手动更改为非透明和白色.

You might have a try to find out if you can detect if there is a color marked as transparent in the incoming picture and then manually change that color to non-transparcy and white before converting the picture.

这篇关于WideImage-转换后的PNG的透明区域应为白色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆