简体   繁体   English

WideImage-将PNG转换为JPEG

[英]WideImage - Transparent PNG to JPEG

Whenever a user uploads a photo using my script, WideImage converts it to JPEG. 每当用户使用我的脚本上传照片时,WideImage都会将其转换为JPEG。 However, I just noticed that if I upload a PNG picture, with a transparent background, it makes it black instead. 但是,我只是注意到,如果我上传带有透明背景的PNG图片,则会将其改为黑色。

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);

Edit 编辑

I looked through the API and I don't see anything for setting the BG color on resizeDown or changing the alpha channel on the PNG before resizeDown... I do however, think that you can use the merge method to merge the PNG with a white background image. 我查看了一下API,但没有看到在resizeDown上设置BG颜色或在resizeDown之前更改PNG上的Alpha通道的任何信息。但是,我认为您可以使用merge方法将PNG与白色背景图像。 Take a look at the API for that function, essentially the PNG image would be the "watermark". 看一下该函数的API,从本质上讲,PNG图像就是“水印”。

http://wideimage.sourceforge.net/wp-content/current/doc/WideImage/WideImage_Image.html#methodmerge http://wideimage.sourceforge.net/wp-content/current/doc/WideImage/WideImage_Image.html#methodmerge


Posting some code might help... you might be able to use this method 发布一些代码可能会有所帮助...您也许可以使用此方法

$white = $image->allocateColor(255, 255, 255); $ white = $ image-> allocateColor(255,255,255);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM