当前位置:首页 » 编程语言 » php图片透明

php图片透明

发布时间: 2024-07-28 16:44:07

phpcms png透明图片裁剪后变成黑底请各位高手给出解决方式

1、png透明图片,裁剪后不会变成黑底。
2、即使有意把图层合并了,它也是白色的背景,不可能变成黑色背景。

❷ php如何判断图片是透明图

用php的扩张imagick 来做 getImageAlphaChannel方法来判断

❸ php怎么输出背景透明的图片

php可以使用GD库或者ImageMagick工具生成png或者gif的背景透明图片.推荐使用ImageMagick.
这里有范例 http://php.net/manual/en/imagick.examples-1.php
准备一张png图片,放到php文件的目录,运行看看效果.
<?php
/* Read the image */
$im = new Imagick("test.png");
/* Thumbnail the image */
$im->thumbnailImage(200, null);

/* Create a border for the image */
$im->borderImage(new ImagickPixel("white"), 5, 5);

/* Clone the image and flip it */
$reflection = $im->clone();
$reflection->flipImage();

/* Create gradient. It will be overlayed on the reflection */
$gradient = new Imagick();

/* Gradient needs to be large enough for the image and the borders */
$gradient->newPseudoImage($reflection->getImageWidth() + 10, $reflection->getImageHeight() + 10, "gradient:transparent-black");

/* Composite the gradient on the reflection */
$reflection->compositeImage($gradient, imagick::COMPOSITE_OVER, 0, 0);

/* Add some opacity. Requires ImageMagick 6.2.9 or later */
$reflection->setImageOpacity( 0.3 );

/* Create an empty canvas */
$canvas = new Imagick();

/* Canvas needs to be large enough to hold the both images */
$width = $im->getImageWidth() + 40;
$height = ($im->getImageHeight() * 2) + 30;
$canvas->newImage($width, $height, new ImagickPixel("black"));
$canvas->setImageFormat("png");

/* Composite the original image and the reflection on the canvas */
$canvas->compositeImage($im, imagick::COMPOSITE_OVER, 20, 10);
$canvas->compositeImage($reflection, imagick::COMPOSITE_OVER, 20, $im->getImageHeight() + 10);

/* Output the image*/
header("Content-Type: image/png");
echo $canvas;
?>

热点内容
java直播网站源码 发布:2025-07-04 14:46:35 浏览:169
安卓应用市场消费记录怎么删除 发布:2025-07-04 14:39:47 浏览:30
知道一个服务器的ip地址 发布:2025-07-04 14:20:33 浏览:597
苹果7锁屏密码怎么改 发布:2025-07-04 14:04:44 浏览:710
P三零是什么配置 发布:2025-07-04 13:58:41 浏览:361
哪个安卓机有长方形home键 发布:2025-07-04 13:43:58 浏览:861
android脚本录制 发布:2025-07-04 13:17:47 浏览:342
嵌入式和安卓哪个硬件成本高 发布:2025-07-04 13:05:56 浏览:229
360代理服务器怎么设置 发布:2025-07-04 12:49:49 浏览:515
iphone在哪清除缓存 发布:2025-07-04 12:49:38 浏览:340