How do I fill white background while resize image

前端 未结 2 1793
执笔经年
执笔经年 2020-12-14 23:04

Current background is black. How to change the color to be white?

    #assuming the mime type is correct
    switch ($imgtype) {
        case \'image/jp         


        
2条回答
  •  天命终不由人
    2020-12-14 23:39

    This is working for me. Although it logically seems like it should fill the whole image with the $bgcolor, it only fills the parts that are "behind" the resampled image.

    imagecopyresampled($resized_image, $original_image, $xoffset, $yoffset, 0, 0, $new_width, $new_height, $orig_width, $orig_height);
    $bgcolor = imagecolorallocate($resized_image, $red, $green, $blue);
    imagefill($resized_image, 0, 0, $bgcolor);
    

提交回复
热议问题