Answer the question
In order to leave comments, you need to log in
Why does the transparent background fill incorrectly when converting png to jpg?
Good afternoon.
When uploading a png image to the site, you need to convert it to jpg to reduce the volume. The site runs on Yii and for this task I use this class (GD is used internally).
I encountered strange behavior of the program when converting images to a transparent background. Usually a transparent background is filled with black, but sometimes there are files that have a torn black stroke around the main object in the photo, and then everything is white. This problem does not occur with all files.
Here's an example of an image that converts fine (first a png, then a jpg result):
$h = new СImageHandler();
$h->load('source.png')->save('res.jpg', $h::IMG_JPEG, 90);
Answer the question
In order to leave comments, you need to log in
It's all about saving png in some editors www.artlebedev.ru/tools/technogrette/img/png-3 Try gluing translucent images with a homogeneous background before saving to jpg.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question