我合併了兩個圖像。第一張圖片將始終爲白色,擴展名爲PNG,大小爲1200像素x 628像素。第二張圖片的尺寸是1000px X 495px。但是,當我合併圖像,然後將白色圖像轉換成黑色圖像。並顯示第二張圖像的背景爲黑色。 請幫助我如何解決這個問題,並將黑色圖像變成白色圖像。PHP合併圖像
Q
PHP合併圖像
0
A
回答
0
添加以下行代碼,您的問題應該得到解決,
imagealphablending($new_image, false);
imagesavealpha($new_image, true);
$transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
僅供參考,用於調整圖像大小的全部源代碼,
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
if ($this->image_type == IMAGETYPE_PNG){
imagealphablending($new_image, false);
imagesavealpha($new_image, true);
$transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
}
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
相關問題
- 1. 合併圖像php
- 2. PHP GD圖像不合並
- 3. 用PHP合併圖像
- 4. 合併圖像
- 5. 在GD中使用php合併圖像
- 6. 在GD中使用php合併圖像
- 7. 以PHP上傳和合並圖像
- 8. 使用GD與PHP合併圖像
- 9. 在php中合併兩個圖像
- 10. 合併圖像PHP - GIF和JPG
- 11. PHP與imagecopymerge()合併兩個圖像()
- 12. PHP合併圖像保存透明
- 13. 用PHP合併兩個圖像
- 14. 在php中合併兩個圖像
- 15. 合併3個圖像和PHP
- 16. 合併圖像由gd在php
- 17. 使用PHP合併兩個圖像?
- 18. 在PHP中合併透明圖像
- 19. 合併base64圖像
- 20. iphone圖像合併
- 21. Qt圖像合併
- 22. 如何在php中的背景PNG圖像合併圖像
- 23. 合併透明PNG圖像與其他PNG圖像 - PHP
- 24. PHP合併2幅圖像(面部插入到圖像)
- 25. 通過拖放合併(合併)圖像
- 26. 拖動並調整圖像大小並將此圖像放在另一個圖像上併合併到PHP
- 27. Android合併兩張圖像,另一張合併兩張圖像
- 28. facebook圖像與另一圖像合併
- 29. 將圖像與圖像合併
- 30. 如何使用PHP imagecopy()或imagecopymerge()組合/合併兩個圖像?
對不起請你附上你得到的和你想要輸出的東西。 –
哪個庫使用'GD2'或'ImageMagick'顯示你的代碼? – Girish
請同時向我們展示您的當前代碼,否則我們不能幫您 –