Php: resize gif and png images with a transparent background turned black. Resize png

Source: Internet
Author: User
Tags transparent image

Php: resize gif and png images with a transparent background turned black. Resize png

In the work, you need to scale some gif images and then go to Imagecopymerge. However, after using imagecreatetruecolor and imagecopyresampled, you find that the background image is incorrect. The original transparent background image turns black. Later, you can make some modifications:

$ Img = imagecreatetruecolor (0, 200,200); // 2. color $ color = imagecolorallocate ($ img, 255,255,255); // 3. set transparent imagecolortransparent ($ img, $ color); imagefill ($ img, 0, 0, $ color );

Then perform imagecopyresampled and Imagecopymerge.


In Hyun dance, the transparent ring is in GIF format. Why do I use meitu xiuxiu to convert PNG to a GIF with a black background?

The icon displayed after success. So what you see here is not transparent. By confirmation, it will not become transparent. You need to try again. Well, I 'd like to say that you don't have a basemap if you change the image format. Instead, you need to hide the basemap and change it to a transparent image format. If you don't, you can put the picture up. I can help you remove it.

Why does the background color become opaque after a PNG image is converted to a GIF image?

It depends on how you convert it. It is not possible to rename it directly. You have to save it with PS or U5 software.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.