In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "php how to achieve reduction of png pictures without loss of transparent color", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "php how to achieve the reduction of png pictures do not lose transparent color" it!
There are two main ways to use the gd library:
The copy code is as follows:
Imagecolorallocatealpha / / assign colors + alpha
Imagesavealpha / / set to save complete alpha channel information when saving png images
Code example:
The copy code is as follows:
/ / get the source image gd image identifier
$srcImg = imagecreatefrompng ('. / src.png')
$srcWidth = imagesx ($srcImg)
$srcHeight = imagesy ($srcImg)
/ / create a new diagram
$newWidth = round ($srcWidth / 2)
$newHeight = round ($srcHeight / 2)
$newImg = imagecreatetruecolor ($newWidth, $newHeight)
/ / assign color + alpha to fill the new image with color
$alpha = imagecolorallocatealpha ($newImg, 0,0,0127)
Imagefill ($newImg, 0,0, $alpha)
/ / copy the source image to the new image, and set to save the complete alpha channel information when saving the PNG image.
Imagecopyresampled ($newImg, $srcImg, 0,0,0,0, $newWidth, $newHeight, $srcWidth, $srcHeight)
Imagesavealpha ($newImg, true)
Imagepng ($newImg,'. / dst.png')
Thank you for your reading, the above is the "php how to achieve reduction of png pictures without loss of transparent color" of the content, after the study of this article, I believe you on how to achieve php reduction of png pictures without loss of transparent color of this problem has a deeper understanding, the specific use of the situation also need to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.