當前位置:首頁 » 編程語言 » 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;
?>

熱點內容
我的世界多人游戲伺服器載入不出來 發布:2025-04-26 16:31:17 瀏覽:466
usb大容量存儲設備但沒盤符 發布:2025-04-26 16:24:12 瀏覽:769
社保儲蓄卡初始密碼是多少 發布:2025-04-26 16:24:06 瀏覽:590
人工免疫演算法 發布:2025-04-26 16:23:24 瀏覽:994
intintjava 發布:2025-04-26 16:23:17 瀏覽:914
阿里雲伺服器22埠 發布:2025-04-26 16:23:15 瀏覽:341
55英寸海信電視配置太低怎麼辦 發布:2025-04-26 16:21:49 瀏覽:678
linuxctrlz 發布:2025-04-26 16:21:49 瀏覽:945
mysql誤刪資料庫 發布:2025-04-26 16:21:41 瀏覽:447
如何關閉華為的隱私密碼 發布:2025-04-26 16:20:04 瀏覽:120